Now XML files are loaded with tinyxml library

This commit is contained in:
David Capello 2009-12-16 23:24:57 +00:00
parent 11a094cb05
commit 017ece697f
41 changed files with 1220 additions and 1071 deletions

View File

@ -1,3 +1,8 @@
2009-11-27 David Capello <davidcapello@gmail.com>
* Now XML files are loaded with tinyxml library (for better error
handling/reporting).
2009-11-22 David Capello <davidcapello@gmail.com>
* src/jinete/jmanager.cpp (jmanager_generate_messages): Added

View File

@ -61,7 +61,7 @@ CONFIGURATION FILES
aseprite.cfg - Program configuration
data/convmatr.def - Convolutions matrices
data/gui-en.xml - Menu definition and keyboard shortcuts
data/gui.xml - Menu definition and keyboard shortcuts
data/fonts/*.pcx - Fonts to be used in the GUI
data/jids/*.jid - XML files with dialogs

View File

@ -1,361 +0,0 @@
<!-- Allegro Sprite Editor menus & keyboard shortcuts -->
<!-- Copyright (C) 2001-2009 by David Capello -->
<gui>
<!-- keyboard shortcuts -->
<keyboard>
<commands>
<!-- file -->
<key command="new_file" shortcut="Ctrl+N" />
<key command="open_file" shortcut="Ctrl+O" />
<key command="save_file" shortcut="Ctrl+S" />
<key command="save_file_as" shortcut="Ctrl+Shift+S" />
<key command="save_file_copy_as" shortcut="Ctrl+Shift+C" />
<key command="close_file" shortcut="Ctrl+W" />
<key command="close_all_files" shortcut="Ctrl+Shift+W" />
<key command="screen_shot" shortcut="F12" />
<key command="exit" shortcut="Ctrl+Q" />
<key command="exit" shortcut="Esc" />
<!-- edit -->
<key command="undo" shortcut="Ctrl+Z" /> <key command="undo" shortcut="Ctrl+U" />
<key command="redo" shortcut="Ctrl+R" />
<key command="cut" shortcut="Ctrl+X" /> <key command="cut" shortcut="Shift+Del" />
<key command="copy" shortcut="Ctrl+C" /> <key command="copy" shortcut="Ctrl+Ins" />
<key command="paste" shortcut="Ctrl+V" /> <key command="paste" shortcut="Shift+Ins" />
<key command="clear" shortcut="Del" /> <key command="clear" shortcut="Backspace" />
<key command="flip" shortcut="Shift+H">
<param name="target" value="mask" />
<param name="orientation" value="horizontal" />
</key>
<key command="flip" shortcut="Shift+V">
<param name="target" value="mask" />
<param name="orientation" value="vertical" />
</key>
<key command="replace_color" shortcut="Shift+R" />
<key command="invert_color" shortcut="Ctrl+I" />
<!-- sprite -->
<key command="sprite_properties" shortcut="Ctrl+P" />
<!-- layer -->
<key command="layer_properties" shortcut="Shift+P" />
<key command="new_layer" shortcut="Shift+N" />
<key command="goto_previous_layer" shortcut="Down" />
<key command="goto_next_layer" shortcut="Up" />
<!-- frame -->
<key command="new_frame" shortcut="N" />
<key command="frame_properties" shortcut="P" />
<key command="goto_first_frame" shortcut="Home" />
<key command="goto_previous_frame" shortcut="Left" />
<key command="goto_next_frame" shortcut="Right" />
<key command="goto_last_frame" shortcut="End" />
<key command="play_animation" shortcut="Enter" />
<!-- mask -->
<key command="mask_all" shortcut="Ctrl+A" />
<key command="deselect_mask" shortcut="Ctrl+D" />
<key command="reselect_mask" shortcut="Ctrl+Shift+D" />
<key command="invert_mask" shortcut="Ctrl+Shift+I" />
<!-- view -->
<key command="refresh" shortcut="F5" />
<key command="advanced_mode" shortcut="A" />
<key command="make_unique_editor" shortcut="Ctrl+1" />
<key command="split_editor_vertically" shortcut="Ctrl+2" />
<key command="split_editor_horizontally" shortcut="Ctrl+3" />
<key command="close_editor" shortcut="Ctrl+4" />
<key command="preview_fit_to_screen" shortcut="F6" />
<key command="preview_normal" shortcut="F7" />
<key command="preview_tiled" shortcut="F8" />
<key command="show_grid" shortcut="Shift+G" />
<key command="snap_to_grid" shortcut="Shift+S" />
<!-- tools -->
<key command="configure_tools" shortcut="C" />
<key command="film_editor" shortcut="Tab" />
<key command="palette_editor" shortcut="F4" />
<key command="convolution_matrix" shortcut="F9" />
<key command="color_curve" shortcut="Ctrl+M" />
<key command="color_curve" shortcut="F10" />
<key command="tips" shortcut="F1" />
<key command="options" shortcut="Ctrl+Shift+O" />
<!-- others -->
<key command="eyedropper" shortcut="I">
<param name="target" value="background" />
</key>
<key command="eyedropper" shortcut="Shift+I">
<param name="target" value="foreground" />
</key>
<key command="switch_colors" shortcut="X" />
<key command="change_color" shortcut="9">
<param name="target" value="foreground" />
<param name="change" value="decrement-index" />
</key>
<key command="change_color" shortcut="0">
<param name="target" value="foreground" />
<param name="change" value="increment-index" />
</key>
<key command="change_color" shortcut="[">
<param name="target" value="foreground" />
<param name="change" value="decrement-index" />
</key>
<key command="change_color" shortcut="]">
<param name="target" value="foreground" />
<param name="change" value="increment-index" />
</key>
<key command="change_color" shortcut="Ctrl+9">
<param name="target" value="background" />
<param name="change" value="decrement-index" />
</key>
<key command="change_color" shortcut="Ctrl+0">
<param name="target" value="background" />
<param name="change" value="increment-index" />
</key>
</commands>
<tools>
<key tool="rectangular_marquee" shortcut="M" />
<key tool="eraser" shortcut="E" />
<key tool="pencil" shortcut="B" />
<key tool="brush" shortcut="B" />
<key tool="spray" shortcut="S" />
<key tool="paint_bucket" shortcut="G" />
<key tool="line" shortcut="L" />
<key tool="curve" shortcut="V" />
<key tool="rectangle" shortcut="U" />
<key tool="ellipse" shortcut="O" />
<key tool="ellipse" shortcut="U" />
<key tool="blur" shortcut="R" />
<key tool="jumble" shortcut="J" />
</tools>
</keyboard>
<!-- main bar menu -->
<menu id="main_menu">
<menu name="&File">
<item command="new_file" name="&New..." />
<item command="open_file" name="&Open..." />
<item id="recent_list" name="Open &Recent" />
<separator />
<item command="save_file" name="&Save" />
<item command="save_file_as" name="Save &As..." />
<item command="save_file_copy_as" name="Save Cop&y As..." />
<item command="close_file" name="&Close" />
<item command="close_all_files" name="Close All" />
<separator />
<menu name="Ca&pture">
<item command="screen_shot" name="Screen Shot" />
<item command="record_screen" name="Record Screen" />
</menu>
<separator />
<item command="exit" name="E&xit" />
</menu>
<menu name="&Edit">
<item command="undo" name="&Undo" />
<item command="redo" name="&Redo" />
<separator />
<item command="cut" name="Cu&t" />
<item command="copy" name="&Copy" />
<item command="paste" name="&Paste" />
<item command="clear" name="C&lear" />
<separator />
<item command="flip" name="Flip &Horizontal">
<param name="target" value="mask" />
<param name="orientation" value="horizontal" />
</item>
<item command="flip" name="Flip &Vertical">
<param name="target" value="mask" />
<param name="orientation" value="vertical" />
</item>
<separator />
<item command="replace_color" name="R&eplace Color..." />
<item command="invert_color" name="&Invert" />
</menu>
<menu name="&Sprite">
<item command="sprite_properties" name="&Properties..." />
<menu name name="Color &Mode">
<item command="change_image_type" name="&RGB Color">
<param name="imgtype" value="rgb" />
</item>
<item command="change_image_type" name="&Grayscale">
<param name="imgtype" value="grayscale" />
</item>
<item command="change_image_type" name="&Indexed (No Dithering)">
<param name="imgtype" value="indexed" />
</item>
<item command="change_image_type" name="Indexed (Ordered &Dither)">
<param name="imgtype" value="indexed" />
<param name="dithering" value="ordered" />
</item>
</menu>
<separator />
<item command="duplicate_sprite" name="&Duplicate..." />
<separator />
<item command="sprite_size" name="&Sprite Size..." />
<item command="canvas_size" name="&Canvas Size..." />
<menu name name="&Rotate Canvas">
<item command="rotate_canvas" name="180">
<param name="angle" value="180" />
</item>
<item command="rotate_canvas" name="90 CW">
<param name="angle" value="90" />
</item>
<item command="rotate_canvas" name="90 CCW">
<param name="angle" value="-90" />
</item>
<separator />
<item command="flip" name="Flip Canvas &Horizontal">
<param name="target" value="canvas" />
<param name="orientation" value="horizontal" />
</item>
<item command="flip" name="Flip Canvas &Vertical">
<param name="target" value="canvas" />
<param name="orientation" value="vertical" />
</item>
</menu>
<separator />
<item command="crop_sprite" name="Cr&op" />
<item command="autocrop_sprite" name="&Trim" />
</menu>
<menu name="&Layer">
<item command="layer_properties" name="&Properties..." />
<separator />
<item command="new_layer" name="&New Layer..." />
<item command="remove_layer" name="&Remove Layer" />
<item command="background_from_layer" name="&Background from Layer" />
<item command="layer_from_background" name="&Layer from Background" />
<separator />
<item command="duplicate_layer" name="&Duplicate..." />
<item command="merge_down_layer" name="&Merge Down" />
<item command="flatten_layers" name="&Flatten" />
</menu>
<menu name="F&rame">
<item command="frame_properties" name="&Properties..." />
<separator />
<item command="new_frame" name="&New Frame" />
<item command="remove_frame" name="&Remove Frame" />
<separator />
<menu name="&Jump to">
<item command="goto_first_frame" name="&First Frame" />
<item command="goto_previous_frame" name="&Previous Frame" />
<item command="goto_next_frame" name="&Next Frame" />
<item command="goto_last_frame" name="&Last Frame" />
</menu>
<item command="play_animation" name="&Play Animation" />
</menu>
<menu name="&Cel">
<item command="cel_properties" name="&Properties..." />
</menu>
<menu name="&Mask">
<item command="mask_all" name="&All" />
<item command="deselect_mask" name="&Deselect" />
<item command="reselect_mask" name="&Reselect" />
<item command="invert_mask" name="&Inverse" />
<separator />
<item command="mask_by_color" name="&Color Range" />
<separator />
<item command="load_mask" name="&Load from MSK file" />
<item command="save_mask" name="&Save to MSK file" />
</menu>
<menu name="&View">
<item command="advanced_mode" name="&Advanced Mode" />
<menu name="&Editor">
<item command="make_unique_editor" name="Make &Unique" />
<separator />
<item command="split_editor_vertically" name="Split &Vertically" />
<item command="split_editor_horizontally" name="Split &Horizontally" />
<separator />
<item command="close_editor" name="&Close" />
</menu>
<separator />
<menu name="&Grid">
<item command="show_grid" name="Show &Grid" />
<item command="snap_to_grid" name="&Snap to Grid" />
</menu>
<menu name="&Preview">
<item command="preview_fit_to_screen" name="&Fit to screen" />
<item command="preview_normal" name="&Normal" />
<item command="preview_tiled" name="&Tiled" />
</menu>
<separator />
<item command="refresh" name="&Refresh" />
<item command="configure_screen" name="Configure &Screen" />
</menu>
<menu name="&Tools">
<item command="configure_tools" name="&Configure" />
<separator />
<item command="film_editor" name="&Animation Editor" />
<item command="palette_editor" name="&Palette Editor" />
<separator />
<menu name="F&X" id="fx_popup">
<item command="convolution_matrix" name="Convolution &Matrix" />
<item command="color_curve" name="&Color Curve" />
<separator />
<item command="despeckle" name="&Despeckle (median filter)" />
</menu>
<separator />
<item command="options" name="&Options" />
</menu>
<menu name="&Help">
<item command="tips" name="&Tips" />
<separator />
<item command="about" name="&About" />
</menu>
</menu>
<menu id="layer_popup">
<item command="layer_properties" name="&Properties..." />
<separator />
<item command="new_layer" name="&New..." />
<item command="remove_layer" name="&Remove" />
<item command="background_from_layer" name="&Background from Layer" />
<item command="layer_from_background" name="&Layer from Background" />
<separator />
<item command="duplicate_layer" name="&Duplicate..." />
<item command="merge_down_layer" name="&Merge Down" />
<item command="flatten_layers" name="&Flatten" />
</menu>
<menu id="frame_popup">
<item command="frame_properties" name="&Properties..." />
<separator />
<item command="new_frame" name="&New" />
<item command="remove_frame" name="&Remove" />
</menu>
<menu id="cel_popup">
<item command="cel_properties" name="&Properties..." />
<separator />
<item command="clear" name="&Clear" />
</menu>
<menu id="cel_movement_popup">
<item command="move_cel" name="&Move" />
<item command="copy_cel" name="&Copy" />
</menu>
<!-- resolutions -->
<resolutions>
<screensize width="320" height="200" aspect="16:10" />
<screensize width="320" height="240" aspect="4:3" />
<screensize width="640" height="400" aspect="16:10" />
<screensize width="640" height="480" aspect="4:3" />
<screensize width="800" height="600" aspect="4:3" />
<screensize width="1024" height="768" aspect="4:3" />
<screensize width="1280" height="800" aspect="16:10" />
<screensize width="1600" height="900" aspect="16:9" />
<screensize width="1600" height="1200" aspect="4:3" />
<screensize width="1680" height="1050" aspect="16:10" />
<screensize width="1920" height="1200" aspect="16:10" />
<screensize width="2560" height="1600" aspect="16:10" />
<colordepth bpp="8" label="8 bpp (256 colors)" />
<colordepth bpp="15" label="15 bpp (32K colors)" />
<colordepth bpp="16" label="16 bpp (64K colors)" />
<colordepth bpp="24" label="24 bpp (16M colors)" />
<colordepth bpp="32" label="32 bpp (16M colors)" />
<pixelscale factor="1" label="x1 (normal)" />
<pixelscale factor="2" label="x2 (double)" />
<pixelscale factor="3" label="x3 (big)" />
<pixelscale factor="4" label="x4 (huge)" />
</resolutions>
</gui>

362
data/gui.xml Normal file
View File

@ -0,0 +1,362 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ASE menus, tools and keyboard shortcuts -->
<gui>
<!-- keyboard shortcuts -->
<keyboard>
<commands>
<!-- file -->
<key command="new_file" shortcut="Ctrl+N" />
<key command="open_file" shortcut="Ctrl+O" />
<key command="save_file" shortcut="Ctrl+S" />
<key command="save_file_as" shortcut="Ctrl+Shift+S" />
<key command="save_file_copy_as" shortcut="Ctrl+Shift+C" />
<key command="close_file" shortcut="Ctrl+W" />
<key command="close_all_files" shortcut="Ctrl+Shift+W" />
<key command="screen_shot" shortcut="F12" />
<key command="exit" shortcut="Ctrl+Q" />
<key command="exit" shortcut="Esc" />
<!-- edit -->
<key command="undo" shortcut="Ctrl+Z" /> <key command="undo" shortcut="Ctrl+U" />
<key command="redo" shortcut="Ctrl+R" />
<key command="cut" shortcut="Ctrl+X" /> <key command="cut" shortcut="Shift+Del" />
<key command="copy" shortcut="Ctrl+C" /> <key command="copy" shortcut="Ctrl+Ins" />
<key command="paste" shortcut="Ctrl+V" /> <key command="paste" shortcut="Shift+Ins" />
<key command="clear" shortcut="Del" /> <key command="clear" shortcut="Backspace" />
<key command="flip" shortcut="Shift+H">
<param name="target" value="mask" />
<param name="orientation" value="horizontal" />
</key>
<key command="flip" shortcut="Shift+V">
<param name="target" value="mask" />
<param name="orientation" value="vertical" />
</key>
<key command="replace_color" shortcut="Shift+R" />
<key command="invert_color" shortcut="Ctrl+I" />
<!-- sprite -->
<key command="sprite_properties" shortcut="Ctrl+P" />
<!-- layer -->
<key command="layer_properties" shortcut="Shift+P" />
<key command="new_layer" shortcut="Shift+N" />
<key command="goto_previous_layer" shortcut="Down" />
<key command="goto_next_layer" shortcut="Up" />
<!-- frame -->
<key command="new_frame" shortcut="N" />
<key command="frame_properties" shortcut="P" />
<key command="goto_first_frame" shortcut="Home" />
<key command="goto_previous_frame" shortcut="Left" />
<key command="goto_next_frame" shortcut="Right" />
<key command="goto_last_frame" shortcut="End" />
<key command="play_animation" shortcut="Enter" />
<!-- mask -->
<key command="mask_all" shortcut="Ctrl+A" />
<key command="deselect_mask" shortcut="Ctrl+D" />
<key command="reselect_mask" shortcut="Ctrl+Shift+D" />
<key command="invert_mask" shortcut="Ctrl+Shift+I" />
<!-- view -->
<key command="refresh" shortcut="F5" />
<key command="advanced_mode" shortcut="A" />
<key command="make_unique_editor" shortcut="Ctrl+1" />
<key command="split_editor_vertically" shortcut="Ctrl+2" />
<key command="split_editor_horizontally" shortcut="Ctrl+3" />
<key command="close_editor" shortcut="Ctrl+4" />
<key command="preview_fit_to_screen" shortcut="F6" />
<key command="preview_normal" shortcut="F7" />
<key command="preview_tiled" shortcut="F8" />
<key command="show_grid" shortcut="Shift+G" />
<key command="snap_to_grid" shortcut="Shift+S" />
<!-- tools -->
<key command="configure_tools" shortcut="C" />
<key command="film_editor" shortcut="Tab" />
<key command="palette_editor" shortcut="F4" />
<key command="convolution_matrix" shortcut="F9" />
<key command="color_curve" shortcut="Ctrl+M" />
<key command="color_curve" shortcut="F10" />
<key command="tips" shortcut="F1" />
<key command="options" shortcut="Ctrl+Shift+O" />
<!-- others -->
<key command="eyedropper" shortcut="I">
<param name="target" value="background" />
</key>
<key command="eyedropper" shortcut="Shift+I">
<param name="target" value="foreground" />
</key>
<key command="switch_colors" shortcut="X" />
<key command="change_color" shortcut="9">
<param name="target" value="foreground" />
<param name="change" value="decrement-index" />
</key>
<key command="change_color" shortcut="0">
<param name="target" value="foreground" />
<param name="change" value="increment-index" />
</key>
<key command="change_color" shortcut="[">
<param name="target" value="foreground" />
<param name="change" value="decrement-index" />
</key>
<key command="change_color" shortcut="]">
<param name="target" value="foreground" />
<param name="change" value="increment-index" />
</key>
<key command="change_color" shortcut="Ctrl+9">
<param name="target" value="background" />
<param name="change" value="decrement-index" />
</key>
<key command="change_color" shortcut="Ctrl+0">
<param name="target" value="background" />
<param name="change" value="increment-index" />
</key>
</commands>
<tools>
<key tool="rectangular_marquee" shortcut="M" />
<key tool="eraser" shortcut="E" />
<key tool="pencil" shortcut="B" />
<key tool="brush" shortcut="B" />
<key tool="spray" shortcut="S" />
<key tool="paint_bucket" shortcut="G" />
<key tool="line" shortcut="L" />
<key tool="curve" shortcut="V" />
<key tool="rectangle" shortcut="U" />
<key tool="ellipse" shortcut="O" />
<key tool="ellipse" shortcut="U" />
<key tool="blur" shortcut="R" />
<key tool="jumble" shortcut="J" />
</tools>
</keyboard>
<menus>
<!-- main bar menu -->
<menu id="main_menu">
<menu text="&amp;File">
<item command="new_file" text="&amp;New..." />
<item command="open_file" text="&amp;Open..." />
<item id="recent_list" text="Open &amp;Recent" />
<separator />
<item command="save_file" text="&amp;Save" />
<item command="save_file_as" text="Save &amp;As..." />
<item command="save_file_copy_as" text="Save Cop&amp;y As..." />
<item command="close_file" text="&amp;Close" />
<item command="close_all_files" text="Close All" />
<separator />
<menu text="Ca&amp;pture">
<item command="screen_shot" text="Screen Shot" />
<item command="record_screen" text="Record Screen" />
</menu>
<separator />
<item command="exit" text="E&amp;xit" />
</menu>
<menu text="&amp;Edit">
<item command="undo" text="&amp;Undo" />
<item command="redo" text="&amp;Redo" />
<separator />
<item command="cut" text="Cu&amp;t" />
<item command="copy" text="&amp;Copy" />
<item command="paste" text="&amp;Paste" />
<item command="clear" text="C&amp;lear" />
<separator />
<item command="flip" text="Flip &amp;Horizontal">
<param name="target" value="mask" />
<param name="orientation" value="horizontal" />
</item>
<item command="flip" text="Flip &amp;Vertical">
<param name="target" value="mask" />
<param name="orientation" value="vertical" />
</item>
<separator />
<item command="replace_color" text="R&amp;eplace Color..." />
<item command="invert_color" text="&amp;Invert" />
</menu>
<menu text="&amp;Sprite">
<item command="sprite_properties" text="&amp;Properties..." />
<menu text="Color &amp;Mode">
<item command="change_image_type" text="&amp;RGB Color">
<param name="imgtype" value="rgb" />
</item>
<item command="change_image_type" text="&amp;Grayscale">
<param name="imgtype" value="grayscale" />
</item>
<item command="change_image_type" text="&amp;Indexed (No Dithering)">
<param name="imgtype" value="indexed" />
</item>
<item command="change_image_type" text="Indexed (Ordered &amp;Dither)">
<param name="imgtype" value="indexed" />
<param name="dithering" value="ordered" />
</item>
</menu>
<separator />
<item command="duplicate_sprite" text="&amp;Duplicate..." />
<separator />
<item command="sprite_size" text="&amp;Sprite Size..." />
<item command="canvas_size" text="&amp;Canvas Size..." />
<menu text="&amp;Rotate Canvas">
<item command="rotate_canvas" text="180">
<param name="angle" value="180" />
</item>
<item command="rotate_canvas" text="90 CW">
<param name="angle" value="90" />
</item>
<item command="rotate_canvas" text="90 CCW">
<param name="angle" value="-90" />
</item>
<separator />
<item command="flip" text="Flip Canvas &amp;Horizontal">
<param name="target" value="canvas" />
<param name="orientation" value="horizontal" />
</item>
<item command="flip" text="Flip Canvas &amp;Vertical">
<param name="target" value="canvas" />
<param name="orientation" value="vertical" />
</item>
</menu>
<separator />
<item command="crop_sprite" text="Cr&amp;op" />
<item command="autocrop_sprite" text="&amp;Trim" />
</menu>
<menu text="&amp;Layer">
<item command="layer_properties" text="&amp;Properties..." />
<separator />
<item command="new_layer" text="&amp;New Layer..." />
<item command="remove_layer" text="&amp;Remove Layer" />
<item command="background_from_layer" text="&amp;Background from Layer" />
<item command="layer_from_background" text="&amp;Layer from Background" />
<separator />
<item command="duplicate_layer" text="&amp;Duplicate..." />
<item command="merge_down_layer" text="&amp;Merge Down" />
<item command="flatten_layers" text="&amp;Flatten" />
</menu>
<menu text="F&amp;rame">
<item command="frame_properties" text="&amp;Properties..." />
<separator />
<item command="new_frame" text="&amp;New Frame" />
<item command="remove_frame" text="&amp;Remove Frame" />
<separator />
<menu text="&amp;Jump to">
<item command="goto_first_frame" text="&amp;First Frame" />
<item command="goto_previous_frame" text="&amp;Previous Frame" />
<item command="goto_next_frame" text="&amp;Next Frame" />
<item command="goto_last_frame" text="&amp;Last Frame" />
</menu>
<item command="play_animation" text="&amp;Play Animation" />
</menu>
<menu text="&amp;Cel">
<item command="cel_properties" text="&amp;Properties..." />
</menu>
<menu text="&amp;Mask">
<item command="mask_all" text="&amp;All" />
<item command="deselect_mask" text="&amp;Deselect" />
<item command="reselect_mask" text="&amp;Reselect" />
<item command="invert_mask" text="&amp;Inverse" />
<separator />
<item command="mask_by_color" text="&amp;Color Range" />
<separator />
<item command="load_mask" text="&amp;Load from MSK file" />
<item command="save_mask" text="&amp;Save to MSK file" />
</menu>
<menu text="&amp;View">
<item command="advanced_mode" text="&amp;Advanced Mode" />
<menu text="&amp;Editor">
<item command="make_unique_editor" text="Make &amp;Unique" />
<separator />
<item command="split_editor_vertically" text="Split &amp;Vertically" />
<item command="split_editor_horizontally" text="Split &amp;Horizontally" />
<separator />
<item command="close_editor" text="&amp;Close" />
</menu>
<separator />
<menu text="&amp;Grid">
<item command="show_grid" text="Show &amp;Grid" />
<item command="snap_to_grid" text="&amp;Snap to Grid" />
</menu>
<menu text="&amp;Preview">
<item command="preview_fit_to_screen" text="&amp;Fit to screen" />
<item command="preview_normal" text="&amp;Normal" />
<item command="preview_tiled" text="&amp;Tiled" />
</menu>
<separator />
<item command="refresh" text="&amp;Refresh" />
<item command="configure_screen" text="Configure &amp;Screen" />
</menu>
<menu text="&amp;Tools">
<item command="configure_tools" text="&amp;Configure" />
<separator />
<item command="film_editor" text="&amp;Animation Editor" />
<item command="palette_editor" text="&amp;Palette Editor" />
<separator />
<menu text="F&amp;X" id="fx_popup">
<item command="convolution_matrix" text="Convolution &amp;Matrix" />
<item command="color_curve" text="&amp;Color Curve" />
<separator />
<item command="despeckle" text="&amp;Despeckle (median filter)" />
</menu>
<separator />
<item command="options" text="&amp;Options" />
</menu>
<menu text="&amp;Help">
<item command="tips" text="&amp;Tips" />
<separator />
<item command="about" text="&amp;About" />
</menu>
</menu>
<menu id="layer_popup">
<item command="layer_properties" text="&amp;Properties..." />
<separator />
<item command="new_layer" text="&amp;New..." />
<item command="remove_layer" text="&amp;Remove" />
<item command="background_from_layer" text="&amp;Background from Layer" />
<item command="layer_from_background" text="&amp;Layer from Background" />
<separator />
<item command="duplicate_layer" text="&amp;Duplicate..." />
<item command="merge_down_layer" text="&amp;Merge Down" />
<item command="flatten_layers" text="&amp;Flatten" />
</menu>
<menu id="frame_popup">
<item command="frame_properties" text="&amp;Properties..." />
<separator />
<item command="new_frame" text="&amp;New" />
<item command="remove_frame" text="&amp;Remove" />
</menu>
<menu id="cel_popup">
<item command="cel_properties" text="&amp;Properties..." />
<separator />
<item command="clear" text="&amp;Clear" />
</menu>
<menu id="cel_movement_popup">
<item command="move_cel" text="&amp;Move" />
<item command="copy_cel" text="&amp;Copy" />
</menu>
</menus>
<!-- resolutions -->
<resolutions>
<screensize width="320" height="200" aspect="16:10" />
<screensize width="320" height="240" aspect="4:3" />
<screensize width="640" height="400" aspect="16:10" />
<screensize width="640" height="480" aspect="4:3" />
<screensize width="800" height="600" aspect="4:3" />
<screensize width="1024" height="768" aspect="4:3" />
<screensize width="1280" height="800" aspect="16:10" />
<screensize width="1600" height="900" aspect="16:9" />
<screensize width="1600" height="1200" aspect="4:3" />
<screensize width="1680" height="1050" aspect="16:10" />
<screensize width="1920" height="1200" aspect="16:10" />
<screensize width="2560" height="1600" aspect="16:10" />
<colordepth bpp="8" label="8 bpp (256 colors)" />
<colordepth bpp="15" label="15 bpp (32K colors)" />
<colordepth bpp="16" label="16 bpp (64K colors)" />
<colordepth bpp="24" label="24 bpp (16M colors)" />
<colordepth bpp="32" label="32 bpp (16M colors)" />
<pixelscale factor="1" label="x1 (normal)" />
<pixelscale factor="2" label="x2 (double)" />
<pixelscale factor="3" label="x3 (big)" />
<pixelscale factor="4" label="x4 (huge)" />
</resolutions>
</gui>

View File

@ -3,11 +3,11 @@
<jinete>
<window text="Warning - Important" name="advanced_mode_warning">
<grid columns="1">
<label text="You are going to enter in \"Advanced Mode\"." />
<label text="You are going to enter in &quot;Advanced Mode&quot;." />
<label text="" name="warning_label" />
<check text="Don't show this again" name="donot_show" />
<separator horizontal />
<button text="&OK" magnetic minwidth="60" cell_align="center" />
<separator horizontal="true" />
<button text="&amp;OK" magnetic="true" minwidth="60" cell_align="center" />
</grid>
</window>
</jinete>

View File

@ -2,31 +2,31 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Canvas Size" name="canvas_size">
<box vertical>
<box horizontal>
<box vertical homogeneous>
<box vertical="true">
<box horizontal="true">
<box vertical="true" homogeneous="true">
<label text="Left:" />
<label text="Right:" />
</box>
<box vertical homogeneous>
<box vertical="true" homogeneous="true">
<entry text="0" name="left" maxsize="32" maxwidth="64" tooltip="Columns to be added/removed in the left side.\nUse a negative number to remove columns." />
<entry text="0" name="right" maxsize="32" maxwidth="64" tooltip="Columns to be added/removed in the right side.\nUse a negative number to remove columns." />
</box>
<box vertical homogeneous>
<box vertical="true" homogeneous="true">
<label text="Top:" />
<label text="Bottom:" />
</box>
<box vertical homogeneous>
<box vertical="true" homogeneous="true">
<entry text="0" name="top" maxsize="32" maxwidth="64" tooltip="Rows to be added/removed in the top side.\nUse a negative number to remove rows." />
<entry text="0" name="bottom" maxsize="32" maxwidth="64" tooltip="Rows to be added/removed in the bottom side.\nUse a negative number to remove rows." />
</box>
</box>
<separator horizontal />
<box horizontal>
<box horizontal expansive />
<box horizontal homogeneous>
<button text="&OK" name="ok" magnetic width="60" />
<button text="&Cancel" />
<separator horizontal="true" />
<box horizontal="true">
<box horizontal="true" expansive="true" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="ok" magnetic="true" width="60" />
<button text="&amp;Cancel" />
</box>
</box>
</box>

View File

@ -7,19 +7,19 @@
<label name="frame" />
<label text="Position: " />
<label name="pos" readonly tooltip="X axis, Y axis" />
<label name="pos" readonly="true" tooltip="X axis, Y axis" />
<label text="Dimension:" />
<label name="size" readonly tooltip="Width x Height (Memory size)" />
<label name="size" readonly="true" tooltip="Width x Height (Memory size)" />
<label text="Opacity:" />
<slider min=0 max=255 name="opacity" cell_align="horizontal" width="128" />
<slider min="0" max="255" name="opacity" cell_align="horizontal" width="128" />
<separator horizontal cell_hspan="2" />
<separator horizontal="true" cell_hspan="2" />
<box horizontal homogeneous cell_hspan="2" cell_align="right">
<button text="&OK" name="ok" magnetic minwidth="60" />
<button text="&Cancel" />
<box horizontal="true" homogeneous="true" cell_hspan="2" cell_align="right">
<button text="&amp;OK" name="ok" magnetic="true" minwidth="60" />
<button text="&amp;Cancel" />
</box>
</grid>
</window>

View File

@ -2,14 +2,14 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Color Curve" name="color_curve">
<box vertical>
<box horizontal expansive>
<view expansive name="curve" /><!-- custom widget -->
<box vertical>
<button text="&OK" name="button_ok" magnetic />
<button text="&Cancel" />
<box vertical="true">
<box horizontal="true" expansive="true">
<view expansive="true" name="curve" /><!-- custom widget -->
<box vertical="true">
<button text="&amp;OK" name="button_ok" magnetic="true" />
<button text="&amp;Cancel" />
<box name="target" />
<check text="&Preview" name="preview" />
<check text="&amp;Preview" name="preview" />
</box>
</box>
</box>

View File

@ -2,24 +2,24 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Configure Screen" name="configure_screen">
<box vertical>
<box horizontal expansive>
<box vertical homogeneous>
<box vertical="true">
<box horizontal="true" expansive="true">
<box vertical="true" homogeneous="true">
<label text="Resolution:" />
<label text="Color depth:" />
<label text="Pixel scaling:" />
<check text="Fullscreen" name="fullscreen" />
</box>
<box vertical homogeneous expansive>
<box vertical="true" homogeneous="true" expansive="true">
<combobox name="resolution" />
<combobox name="color_depth" />
<combobox name="pixel_scale" />
<label text="" />
</box>
</box>
<box horizontal homogeneous>
<button text="&OK" name="ok" magnetic />
<button text="&Cancel" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="ok" magnetic="true" />
<button text="&amp;Cancel" />
</box>
</box>
</window>

View File

@ -2,62 +2,62 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Convolution Matrix" name="convolution_matrix">
<box vertical>
<box horizontal expansive>
<view expansive name="view" /><!-- custom widget -->
<box vertical>
<button text="&OK" name="button_ok" magnetic />
<button text="&Cancel" />
<box vertical="true">
<box horizontal="true" expansive="true">
<view expansive="true" name="view" /><!-- custom widget -->
<box vertical="true">
<button text="&amp;OK" name="button_ok" magnetic="true" />
<button text="&amp;Cancel" />
<box name="target" />
<check text="&Preview" name="preview" />
<check text="&Tiled" name="tiled" />
<check text="&amp;Preview" name="preview" />
<check text="&amp;Tiled" name="tiled" />
</box>
</box>
<box horizontal>
<button text="&Reload Stock" name="reload" />
<button text="&Generate" name="generate" />
<box horizontal="true">
<button text="&amp;Reload Stock" name="reload" />
<button text="&amp;Generate" name="generate" />
</box>
</box>
</window>
<window text="Generate New Matrix" name="generate_convolution_matrix">
<box vertical>
<box horizontal expansive homogeneous>
<box vertical expansive>
<box vertical="true">
<box horizontal="true" expansive="true" homogeneous="true">
<box vertical="true" expansive="true">
<label text="X axis" />
<view expansive name="view_x" /><!-- custom widget -->
<view expansive="true" name="view_x" /><!-- custom widget -->
</box>
<box vertical expansive>
<box vertical="true" expansive="true">
<label text="Y axis" />
<view expansive name="view_y" /><!-- custom widget -->
<view expansive="true" name="view_y" /><!-- custom widget -->
</box>
</box>
<box horizontal homogeneous>
<box horizontal>
<box vertical homogeneous>
<box horizontal="true" homogeneous="true">
<box horizontal="true">
<box vertical="true" homogeneous="true">
<label text="Width:" />
<label text="Height:" />
</box>
<box vertical homogeneous expansive>
<box vertical="true" homogeneous="true" expansive="true">
<slider min="1" max="31" name="width" />
<slider min="1" max="31" name="height" />
</box>
<box vertical homogeneous>
<box vertical="true" homogeneous="true">
<label text="Div:" />
<label text="Bias:" />
</box>
<box vertical homogeneous expansive>
<entry maxsize=32 name="div" />
<entry maxsize=32 name="bias" />
<box vertical="true" homogeneous="true" expansive="true">
<entry maxsize="32" name="div" />
<entry maxsize="32" name="bias" />
</box>
<box vertical homogeneous>
<box vertical="true" homogeneous="true">
<check text="Auto" name="div_auto" />
<check text="Auto" name="bias_auto" />
</box>
</box>
</box>
<box horizontal homogeneous>
<button text="&OK" name="button_ok" magnetic />
<button text="&Cancel" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="button_ok" magnetic="true" />
<button text="&amp;Cancel" />
</box>
</box>
</window>

View File

@ -2,34 +2,34 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Draw Text" name="drawtext_window">
<box vertical>
<box horizontal>
<box vertical homogeneous>
<box vertical="true">
<box horizontal="true">
<box vertical="true" homogeneous="true">
<label text="Font:" />
<label text="Size:" />
</box>
<box vertical homogeneous expansive>
<box vertical="true" homogeneous="true" expansive="true">
<button text="" name="font" />
<entry maxsize=8 name="size"/>
<entry maxsize="8" name="size"/>
</box>
</box>
<!-- <label text="Fixed Size:" /> -->
<!-- <view expansive> -->
<!-- <view expansive="true"> -->
<!-- <listbox /> -->
<!-- </view> -->
<separator horizontal />
<box horizontal>
<box vertical homogeneous>
<separator horizontal="true" />
<box horizontal="true">
<box vertical="true" homogeneous="true">
<label text="Text:" />
<label text="Color:" />
</box>
<box vertical homogeneous expansive name="color_box">
<entry maxsize=256 name="text" expansive />
<box vertical="true" homogeneous="true" expansive="true" name="color_box">
<entry maxsize="256" name="text" expansive="true" />
</box>
</box>
<box horizontal homogeneous>
<button text="&OK" name="ok" magnetic />
<button text="&Cancel" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="ok" magnetic="true" />
<button text="&amp;Cancel" />
</box>
</box>
</window>

View File

@ -2,21 +2,21 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Duplicate Sprite" name="duplicate_sprite">
<box vertical>
<box horizontal expansive>
<box vertical homogeneous>
<box vertical="true">
<box horizontal="true" expansive="true">
<box vertical="true" homogeneous="true">
<label text="Duplicate:" />
<label text="As:" />
</box>
<box vertical homogeneous expansive>
<box vertical="true" homogeneous="true" expansive="true">
<label text="" name="src_name" />
<entry maxsize="256" name="dst_name" magnetic />
<entry maxsize="256" name="dst_name" magnetic="true" />
</box>
</box>
<check text="Duplicate merged layers only" name="flatten" />
<box horizontal homogeneous>
<button text="&OK" name="ok" magnetic />
<button text="&Cancel" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="ok" magnetic="true" />
<button text="&amp;Cancel" />
</box>
</box>
</window>

View File

@ -2,26 +2,26 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="" name="file_selector">
<box vertical>
<box horizontal>
<box horizontal noborders>
<box vertical="true">
<box horizontal="true">
<box horizontal="true" noborders="true">
<button text="" name="goback" bevel="2 0 2 0" tooltip="Go back one folder" />
<button text="" name="goforward" bevel="0 2 0 2" tooltip="Go forward one folder" />
</box>
<button text="" name="goup" tooltip="Up to parent folder\n(Backspace)" />
<combobox name="location" expansive />
<combobox name="location" expansive="true" />
</box>
<box vertical expansive name="box" />
<box horizontal>
<box vertical="true" expansive="true" name="box" />
<box horizontal="true">
<label text="Name:" />
<entry text="" maxsize=256 name="filename" expansive magnetic />
<combobox name="filetype" minwidth=70 />
<entry text="" maxsize="256" name="filename" expansive="true" magnetic="true" />
<combobox name="filetype" minwidth="70" />
</box>
<box horizontal>
<box horizontal expansive />
<box horizontal homogeneous>
<button text="&OK" name="ok" magnetic width="60" />
<button text="&Cancel" name="cancel" />
<box horizontal="true">
<box horizontal="true" expansive="true" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="ok" magnetic="true" width="60" />
<button text="&amp;Cancel" name="cancel" />
</box>
</box>
</box>

View File

@ -8,15 +8,15 @@
<box cell_align="horizontal" />
<label text="Duration (milliseconds):" />
<entry maxsize="10" name="frlen" magnetic />
<entry maxsize="10" name="frlen" magnetic="true" />
<box cell_align="horizontal" />
<separator horizontal cell_hspan="3" />
<separator horizontal="true" cell_hspan="3" />
<box horizontal homogeneous cell_hspan="3" cell_align="right">
<button text="&OK" name="ok" magnetic minwidth="60" />
<button text="&Cancel" />
<box horizontal="true" homogeneous="true" cell_hspan="3" cell_align="right">
<button text="&amp;OK" name="ok" magnetic="true" minwidth="60" />
<button text="&amp;Cancel" />
</box>
</box>
</grid>
</window>
</jinete>

View File

@ -2,12 +2,12 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Invert Color" name="invert_color">
<box vertical>
<box vertical expansive name="target" />
<check text="&Preview" name="preview" />
<box horizontal homogeneous>
<button text="&OK" name="button_ok" magnetic />
<button text="&Cancel" />
<box vertical="true">
<box vertical="true" expansive="true" name="target" />
<check text="&amp;Preview" name="preview" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="button_ok" magnetic="true" />
<button text="&amp;Cancel" />
</box>
</box>
</window>

View File

@ -4,13 +4,13 @@
<window text="JPEG Options" name="jpeg_options">
<grid columns="2">
<label text="Quality:" />
<slider min=0 max=10 name="quality" cell_align="horizontal" width="128" />
<slider min="0" max="10" name="quality" cell_align="horizontal" width="128" />
<separator horizontal cell_hspan="2" />
<separator horizontal="true" cell_hspan="2" />
<box horizontal homogeneous cell_hspan="2" cell_align="right">
<button text="&OK" name="ok" magnetic minwidth="60" />
<button text="&Cancel" />
<box horizontal="true" homogeneous="true" cell_hspan="2" cell_align="right">
<button text="&amp;OK" name="ok" magnetic="true" minwidth="60" />
<button text="&amp;Cancel" />
</box>
</grid>
</window>

View File

@ -1,16 +1,16 @@
<!-- ASE - Allegro Sprite Editor -->
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window noborders desktop text="Main Window" name="main_window">
<box noborders vertical>
<box noborders horizontal name="menubar" />
<box noborders horizontal name="tabsbar" />
<box noborders horizontal expansive>
<box noborders vertical name="colorbar" />
<box noborders horizontal name="editor" expansive />
<box noborders vertical name="toolbar" />
<window noborders="true" desktop="true" text="Main Window" name="main_window">
<box noborders="true" vertical="true">
<box noborders="true" horizontal="true" name="menubar" />
<box noborders="true" horizontal="true" name="tabsbar" />
<box noborders="true" horizontal="true" expansive="true">
<box noborders="true" vertical="true" name="colorbar" />
<box noborders="true" horizontal="true" name="editor" expansive="true" />
<box noborders="true" vertical="true" name="toolbar" />
</box>
<box noborders horizontal name="statusbar" />
<box noborders="true" horizontal="true" name="statusbar" />
</box>
</window>
</jinete>

View File

@ -2,27 +2,27 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Median Blur" name="median">
<box vertical>
<box horizontal>
<box horizontal expansive>
<box vertical homogeneous>
<box vertical="true">
<box horizontal="true">
<box horizontal="true" expansive="true">
<box vertical="true" homogeneous="true">
<label text="Width:" />
<label text="Height:" />
</box>
<box vertical homogeneous expansive>
<entry expansive name="width" maxsize=4 />
<entry expansive name="height" maxsize=4 />
<box vertical="true" homogeneous="true" expansive="true">
<entry expansive="true" name="width" maxsize="4" />
<entry expansive="true" name="height" maxsize="4" />
</box>
</box>
<box vertical>
<box vertical="true">
<box name="target" />
<check text="&Preview" name="preview" />
<check text="&Tiled" name="tiled" />
<check text="&amp;Preview" name="preview" />
<check text="&amp;Tiled" name="tiled" />
</box>
</box>
<box horizontal homogeneous expansive>
<button text="&OK" name="button_ok" magnetic />
<button text="&Cancel" />
<box horizontal="true" homogeneous="true" expansive="true">
<button text="&amp;OK" name="button_ok" magnetic="true" />
<button text="&amp;Cancel" />
</box>
</box>
</window>

View File

@ -2,30 +2,30 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="New Image Layer" name="new_layer">
<box vertical>
<box horizontal>
<box vertical homogeneous>
<box vertical="true">
<box horizontal="true">
<box vertical="true" homogeneous="true">
<label text="Name:" />
</box>
<box vertical homogeneous>
<entry maxsize=256 text="New Layer" name="name" magnetic />
<box vertical="true" homogeneous="true">
<entry maxsize="256" text="New Layer" name="name" magnetic="true" />
</box>
</box>
<box horizontal homogeneous>
<button text="&OK" name="ok" magnetic />
<button text="&Cancel" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="ok" magnetic="true" />
<button text="&amp;Cancel" />
</box>
</box>
</window>
<window text="New Layer Set" name="new_layer_set">
<box vertical>
<box horizontal>
<box vertical="true">
<box horizontal="true">
<label text="Name:" />
<entry maxsize=256 text="New Set" name="name" />
<entry maxsize="256" text="New Set" name="name" />
</box>
<box horizontal homogeneous>
<button text="&OK" name="ok" magnetic />
<button text="&Cancel" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="ok" magnetic="true" />
<button text="&amp;Cancel" />
</box>
</box>
</window>

View File

@ -2,34 +2,34 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="New Sprite" name="new_sprite">
<box vertical>
<box horizontal>
<box vertical expansive>
<separator text="Size:" left horizontal />
<box vertical expansive>
<box horizontal>
<box vertical homogeneous>
<box vertical="true">
<box horizontal="true">
<box vertical="true" expansive="true">
<separator text="Size:" left="true" horizontal="true" />
<box vertical="true" expansive="true">
<box horizontal="true">
<box vertical="true" homogeneous="true">
<label text="Width:" />
<label text="Height:" />
</box>
<box vertical homogeneous expansive>
<entry expansive name="width" maxsize=8 magnetic tooltip="Width of the new sprite (in pixels)" />
<entry expansive name="height" maxsize=8 tooltip="Height of the new sprite (in pixels)" />
<box vertical="true" homogeneous="true" expansive="true">
<entry expansive="true" name="width" maxsize="8" magnetic="true" tooltip="Width of the new sprite (in pixels)" />
<entry expansive="true" name="height" maxsize="8" tooltip="Height of the new sprite (in pixels)" />
</box>
</box>
</box>
</box>
<box vertical>
<separator text="Color Mode:" left horizontal />
<box vertical homogeneous>
<radio name="radio1" text="&RGB Color" group=1 tooltip="RGBA color mode\n(32 bits per pixel)" />
<radio name="radio2" text="&Grayscale" group=1 tooltip="Value and Alpha\n(16 bits per pixel)" />
<radio name="radio3" text="&Indexed" group=1 tooltip="Using a palette of 256 colors\n(8 bits per pixel)" />
<box vertical="true">
<separator text="Color Mode:" left="true" horizontal="true" />
<box vertical="true" homogeneous="true">
<radio name="radio1" text="&amp;RGB Color" group="1" tooltip="RGBA color mode\n(32 bits per pixel)" />
<radio name="radio2" text="&amp;Grayscale" group="1" tooltip="Value and Alpha\n(16 bits per pixel)" />
<radio name="radio3" text="&amp;Indexed" group="1" tooltip="Using a palette of 256 colors\n(8 bits per pixel)" />
</box>
</box>
</box>
<separator text="Background:" left horizontal />
<view maxsize expansive>
<separator text="Background:" left="true" horizontal="true" />
<view maxsize="true" expansive="true">
<listbox name="bg_box">
<listitem text="Transparent" />
<listitem text="Black" />
@ -39,11 +39,11 @@
</listbox>
</view>
<box horizontal>
<box horizontal expansive />
<box horizontal homogeneous>
<button text="&OK" name="ok_button" magnetic width="60" />
<button text="&Cancel" />
<box horizontal="true">
<box horizontal="true" expansive="true" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="ok_button" magnetic="true" width="60" />
<button text="&amp;Cancel" />
</box>
</box>
</box>

View File

@ -2,30 +2,30 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Options" name="options">
<box vertical>
<box vertical>
<box vertical="true">
<box vertical="true">
<label text="Mouse Speed:" />
<box horizontal>
<box vertical homogeneous>
<box horizontal="true">
<box vertical="true" homogeneous="true">
<label text="X:" />
<label text="Y:" />
</box>
<box vertical homogeneous expansive>
<box vertical="true" homogeneous="true" expansive="true">
<slider min="-8" max="8" name="mouse_x" />
<slider min="-8" max="8" name="mouse_y" />
</box>
</box>
<check text="Lock X/Y" name="lock_axis" />
<separator horizontal />
<separator horizontal="true" />
<check text="Smooth auto-scroll" name="smooth" />
<check text="Real-time ordered dithering" name="dither" />
<check text="2 Click Movement" name="move_click2" />
<check text="2 Click Drawing" name="draw_click2" />
<box horizontal>
<box horizontal="true">
<label text="Undo size limit:" />
<entry name="undo_size_limit" maxsize="4" tooltip="Limit of memory to be used\nfor undo information per sprite.\nSpecified in megabytes." />
<label text="MB" />
@ -33,11 +33,11 @@
</box>
<box horizontal>
<box horizontal expansive />
<box horizontal homogeneous>
<button text="&OK" name="button_ok" magnetic width="60" />
<button text="&Cancel" />
<box horizontal="true">
<box horizontal="true" expansive="true" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="button_ok" magnetic="true" width="60" />
<button text="&amp;Cancel" />
</box>
</box>
</box>

View File

@ -2,64 +2,64 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Palette Editor" name="palette_editor">
<box vertical>
<box horizontal expansive>
<box vertical>
<view name="palette_editor" expansive /> <!-- custom-widget -->
<box vertical="true">
<box horizontal="true" expansive="true">
<box vertical="true">
<view name="palette_editor" expansive="true" /> <!-- custom-widget -->
<slider min="1" max="256" name="columns" />
</box>
<box vertical expansive>
<box horizontal>
<box vertical homogeneous>
<box vertical="true" expansive="true">
<box horizontal="true">
<box vertical="true" homogeneous="true">
<label text="R" />
<label text="G" />
<label text="B" />
</box>
<box vertical homogeneous expansive>
<box vertical="true" homogeneous="true" expansive="true">
<slider min="0" max="255" name="red" />
<slider min="0" max="255" name="green" />
<slider min="0" max="255" name="blue" />
</box>
<box vertical homogeneous>
<box vertical="true" homogeneous="true">
<label text="H" />
<label text="S" />
<label text="V" />
</box>
<box vertical homogeneous expansive>
<box vertical="true" homogeneous="true" expansive="true">
<slider min="0" max="255" name="hue" />
<slider min="0" max="255" name="saturation" />
<slider min="0" max="255" name="value" />
</box>
</box>
<box name="colorviewer" expansive /> <!-- custom-widget -->
<button text="Select &All" name="select_all" />
<box vertical>
<box horizontal homogeneous>
<button text="&Undo" name="undo" />
<button text="&Redo" name="redo" />
<box name="colorviewer" expansive="true" /> <!-- custom-widget -->
<button text="Select &amp;All" name="select_all" />
<box vertical="true">
<box horizontal="true" homogeneous="true">
<button text="&amp;Undo" name="undo" />
<button text="&amp;Redo" name="redo" />
</box>
<box horizontal homogeneous>
<button text="&Load" name="load" />
<button text="&Save" name="save" />
<box horizontal="true" homogeneous="true">
<button text="&amp;Load" name="load" />
<button text="&amp;Save" name="save" />
</box>
<box horizontal homogeneous>
<button text="&Ramp" name="ramp" />
<button text="&Quantize" name="quantize" />
<box horizontal="true" homogeneous="true">
<button text="&amp;Ramp" name="ramp" />
<button text="&amp;Quantize" name="quantize" />
</box>
</box>
</box>
</box>
<box horizontal >
<box horizontal="true">
<label text="Frame:" />
<slider min="0" max="1" name="frame" expansive />
<slider min="0" max="1" name="frame" expansive="true" />
</box>
<box horizontal>
<box horizontal="true">
<check name="all_frames" text="All frames the same palette" />
<box horizontal expansive />
<box horizontal homogeneous>
<button text="&OK" name="button_ok" magnetic width="60" />
<button text="&Cancel" />
<box horizontal="true" expansive="true" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="button_ok" magnetic="true" width="60" />
<button text="&amp;Cancel" />
</box>
</box>
</box>

View File

@ -2,13 +2,13 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Play FLI/FLC" name="play_fli">
<box vertical>
<box vertical="true">
<check text="Loop" name="loop" />
<check text="Fullscreen" name="fullscreen" />
<button text="&Open" name="button_open" />
<box horizontal homogeneous expansive>
<button text="&Play" name="button_play" magnetic />
<button text="&Close" />
<button text="&amp;Open" name="button_open" />
<box horizontal="true" homogeneous="true" expansive="true">
<button text="&amp;Play" name="button_play" magnetic="true" />
<button text="&amp;Close" />
</box>
</box>
</window>

View File

@ -2,20 +2,20 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Point Properties" name="point_properties">
<box vertical>
<box horizontal expansive>
<box vertical homogeneous>
<box vertical="true">
<box horizontal="true" expansive="true">
<box vertical="true" homogeneous="true">
<label text="X:" />
<label text="Y:" />
</box>
<box vertical homogeneous expansive>
<entry maxsize="32" name="x" magnetic />
<box vertical="true" homogeneous="true" expansive="true">
<entry maxsize="32" name="x" magnetic="true" />
<entry maxsize="32" name="y" />
</box>
</box>
<box horizontal homogeneous>
<button text="&OK" name="button_ok" magnetic />
<button text="&Cancel" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="button_ok" magnetic="true" />
<button text="&amp;Cancel" />
</box>
</box>
</window>

View File

@ -2,23 +2,23 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Replace Color" name="replace_color">
<box horizontal>
<box vertical expansive>
<box horizontal expansive>
<box vertical homogeneous>
<box horizontal="true">
<box vertical="true" expansive="true">
<box horizontal="true" expansive="true">
<box vertical="true" homogeneous="true">
<label text="From:" />
<label text="To:" />
</box>
<box vertical homogeneous expansive name="color_buttons_box" />
<box vertical="true" homogeneous="true" expansive="true" name="color_buttons_box" />
</box>
<label text="Fuzziness:" />
<slider min=0 max=255 name="fuzziness" />
<slider min="0" max="255" name="fuzziness" />
</box>
<box vertical>
<button text="&OK" name="button_ok" magnetic />
<button text="&Cancel" />
<box vertical="true">
<button text="&amp;OK" name="button_ok" magnetic="true" />
<button text="&amp;Cancel" />
<box name="target" />
<check text="&Preview" name="preview" />
<check text="&amp;Preview" name="preview" />
</box>
</box>
</window>

View File

@ -2,28 +2,28 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Sprite Properties" name="sprite_properties">
<box vertical>
<box horizontal expansive>
<box vertical homogeneous>
<box vertical="true">
<box horizontal="true" expansive="true">
<box vertical="true" homogeneous="true">
<label text="File name:" />
<label text="Type:" />
<label text="Size:" />
<label text="Frames:" />
</box>
<box vertical homogeneous expansive>
<entry text="" name="name" maxsize="256" readonly maxwidth="100" />
<box vertical="true" homogeneous="true" expansive="true">
<entry text="" name="name" maxsize="256" readonly="true" maxwidth="100" />
<label text="" name="type" />
<label text="" name="size" />
<label text="" name="frames" />
</box>
</box>
<separator horizontal />
<box horizontal>
<separator horizontal="true" />
<box horizontal="true">
<button text="Constant Frame-Rate Speed" name="speed" />
<box horizontal expansive />
<box horizontal homogeneous>
<button text="&OK" name="ok" magnetic width="60" />
<button text="&Cancel" />
<box horizontal="true" expansive="true" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="ok" magnetic="true" width="60" />
<button text="&amp;Cancel" />
</box>
</box>
</box>

View File

@ -2,49 +2,49 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Sprite Size" name="sprite_size">
<box vertical>
<box vertical>
<separator text="Pixels:" left horizontal />
<box vertical expansive>
<box horizontal>
<box vertical homogeneous>
<box vertical="true">
<box vertical="true">
<separator text="Pixels:" left="true" horizontal="true" />
<box vertical="true" expansive="true">
<box horizontal="true">
<box vertical="true" homogeneous="true">
<label text="Width:" />
<label text="Height:" />
</box>
<box vertical homogeneous expansive>
<entry expansive name="width_px" maxsize=8 magnetic tooltip="New width for the sprite (in pixels)" />
<entry expansive name="height_px" maxsize=8 tooltip="New height for the sprite (in pixels)" />
<box vertical="true" homogeneous="true" expansive="true">
<entry expansive="true" name="width_px" maxsize="8" magnetic="true" tooltip="New width for the sprite (in pixels)" />
<entry expansive="true" name="height_px" maxsize="8" tooltip="New height for the sprite (in pixels)" />
</box>
<check text="Lock Ratio" name="lock_ratio" selected />
<check text="Lock Ratio" name="lock_ratio" selected="true" />
</box>
</box>
<separator text="Percentage:" left horizontal />
<box vertical expansive>
<box horizontal>
<box vertical homogeneous>
<separator text="Percentage:" left="true" horizontal="true" />
<box vertical="true" expansive="true">
<box horizontal="true">
<box vertical="true" homogeneous="true">
<label text="Width:" />
<label text="Height:" />
</box>
<box vertical homogeneous expansive>
<entry expansive text="100%%" name="width_perc" maxsize=8 magnetic tooltip="New width for the sprite\nPercentage of current width." />
<entry expansive text="100%%" name="height_perc" maxsize=8 tooltip="New height for the sprite\nPercentage of current height." />
<box vertical="true" homogeneous="true" expansive="true">
<entry expansive="true" text="100%%" name="width_perc" maxsize="8" magnetic="true" tooltip="New width for the sprite\nPercentage of current width." />
<entry expansive="true" text="100%%" name="height_perc" maxsize="8" tooltip="New height for the sprite\nPercentage of current height." />
</box>
<box horizontal width="64" />
<box horizontal="true" width="64" />
</box>
</box>
</box>
<separator text="Interpolation:" left horizontal />
<box vertical expansive>
<box horizontal>
<separator text="Interpolation:" left="true" horizontal="true" />
<box vertical="true" expansive="true">
<box horizontal="true">
<label text="Method:" />
<combobox name="method" expansive />
<combobox name="method" expansive="true" />
</box>
</box>
<box horizontal>
<box horizontal expansive />
<box horizontal homogeneous>
<button text="&OK" name="ok" magnetic width="60" />
<button text="&Cancel" />
<box horizontal="true">
<box horizontal="true" expansive="true" />
<box horizontal="true" homogeneous="true">
<button text="&amp;OK" name="ok" magnetic="true" width="60" />
<button text="&amp;Cancel" />
</box>
</box>
</box>

View File

@ -2,52 +2,52 @@
<!-- Copyright (C) 2001-2009 by David Capello -->
<jinete>
<window text="Tools Configuration" name="configure_tool">
<box vertical>
<box horizontal expansive>
<box vertical>
<separator text="General:" horizontal left />
<box vertical="true">
<box horizontal="true" expansive="true">
<box vertical="true">
<separator text="General:" horizontal="true" left="true" />
<check text="Filled" name="filled" />
<box horizontal childspacing="0">
<box horizontal="true" childspacing="0">
<check text="Tiled" name="tiled" />
<check text="x" name="tiled_x" />
<check text="y" name="tiled_y" />
</box>
<check text="Onionskin" name="onionskin" />
<separator text="Grid:" horizontal left />
<separator text="Grid:" horizontal="true" left="true" />
<check text="Snap to Grid" name="use_grid" />
<check text="View Grid" name="view_grid" />
<button text="Set &Grid" name="set_grid" />
<separator text="Cursor:" horizontal left />
<button text="Set &amp;Grid" name="set_grid" />
<separator text="Cursor:" horizontal="true" left="true" />
<box name="cursor_color_box" /><!-- custom widget -->
</box>
<box vertical expansive>
<separator text="Brush:" horizontal left />
<box horizontal>
<box vertical homogeneous>
<box vertical="true" expansive="true">
<separator text="Brush:" horizontal="true" left="true" />
<box horizontal="true">
<box vertical="true" homogeneous="true">
<label text="Size:" />
<label text="Angle:" />
</box>
<box vertical homogeneous expansive>
<slider min=1 max=32 name="brush_size" minwidth="128" />
<slider min=0 max=180 name="brush_angle" />
<box vertical="true" homogeneous="true" expansive="true">
<slider min="1" max="32" name="brush_size" minwidth="128" />
<slider min="0" max="180" name="brush_angle" />
</box>
<box vertical homogeneous>
<box vertical="true" homogeneous="true">
<box name="brush_type_box" /><!-- custom widget -->
<box name="brush_mode_box" /><!-- custom widget -->
</box>
<box name="brush_preview_box" /><!-- custom widget -->
</box>
<separator text="Opacity:" horizontal left />
<slider min=0 max=255 name="glass_dirty" />
<separator text="Spray:" horizontal left />
<box horizontal>
<box vertical homogeneous>
<separator text="Opacity:" horizontal="true" left="true" />
<slider min="0" max="255" name="glass_dirty" />
<separator text="Spray:" horizontal="true" left="true" />
<box horizontal="true">
<box vertical="true" homogeneous="true">
<label text="Spray Width:" />
<label text="Air Speed:" />
</box>
<box vertical homogeneous expansive>
<slider min=1 max=32 name="spray_width" />
<slider min=1 max=100 name="air_speed" />
<box vertical="true" homogeneous="true" expansive="true">
<slider min="1" max="32" name="spray_width" />
<slider min="1" max="100" name="air_speed" />
</box>
</box>
</box>

View File

@ -566,7 +566,7 @@ Here you have some explanation about how to customize your own copy of
ASE. Take care of all modifications you made in configuration files, and
make sure you have a backup copy of everything.
Most of the customizable UI elements are taken from ``<ase-folder>/data/gui-en.xml`` file.
Most of the customizable UI elements are taken from ``<ase-folder>/data/gui.xml`` file.
Keyboard Shortcuts
==================
@ -595,7 +595,7 @@ Menus
Tools
=====
In the ``data/gui-en.xml`` file you will found a the following sections:
In the ``data/gui.xml`` file you will found a the following sections:
::

View File

@ -125,6 +125,7 @@ COMMON_SOURCES = \
src/jinete/jcombobox.cpp \
src/jinete/jdraw.cpp \
src/jinete/jentry.cpp \
src/jinete/jexception.cpp \
src/jinete/jgrid.cpp \
src/jinete/jfile.cpp \
src/jinete/jfilesel.cpp \
@ -231,6 +232,7 @@ COMMON_OBJS = $(addprefix $(OBJ_DIR)/, \
ASE_SOURCES = \
src/app.cpp \
src/ase_exception.cpp \
src/console.cpp \
src/context.cpp \
src/main.cpp \

View File

@ -72,7 +72,7 @@ ase_files="config.h \
*.txt \
data/aseicon.* \
data/convmatr.def \
data/gui-en.xml \
data/*.xml \
data/fonts/*.pcx \
data/jids/*.jid \
data/palettes/*.col \
@ -175,7 +175,7 @@ $1/WARNING.txt \
$1/COPYING \
$1/data/convmatr.def \
$1/data/jids/*.jid \
$1/data/gui-en.xml \
$1/data/*.xml \
$1/data/tips/*.en \
$1/docs/*.pdf \
$1/docs/files/*.txt \

53
src/ase_exception.cpp Normal file
View File

@ -0,0 +1,53 @@
/* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2009 David Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <allegro/unicode.h>
#include <stdio.h>
#include "ase_exception.h"
#include "console.h"
ase_exception::ase_exception(const char* msg, ...) throw()
{
try {
if (!ustrchr(msg, '%')) {
m_msg = msg;
}
else {
va_list ap;
va_start(ap, msg);
char buf[1024]; // TODO warning buffer overflow
uvsprintf(buf, msg, ap);
m_msg = buf;
va_end(ap);
}
}
catch (...) {
// no throw
}
}
void ase_exception::show()
{
Console console;
console.printf("An error occurred.\n\nDetails:\n%s", what());
}

View File

@ -19,40 +19,19 @@
#ifndef ASE_EXCEPTION_H_INCLUDED
#define ASE_EXCEPTION_H_INCLUDED
#include <exception>
#include <string>
#include "console.h"
#include "jinete/jexception.h"
class ase_exception : public std::exception
class ase_exception : public jexception
{
std::string m_msg;
public:
ase_exception(const char* msg) throw()
: m_msg(msg)
{
}
ase_exception() throw() { }
ase_exception(const char* msg, ...) throw();
ase_exception(const std::string& msg) throw() : jexception(msg) { }
ase_exception(TiXmlDocument* doc) throw() : jexception(doc) { }
~ase_exception() throw() { }
ase_exception(const std::string& msg) throw()
: m_msg(msg)
{
}
virtual ~ase_exception() throw()
{
}
void show()
{
Console console;
console.printf("An error ocurred executing the command.\n\nDetails:\n%s", what());
}
const char* what() const throw()
{
return m_msg.c_str();
}
virtual void show();
};

View File

@ -34,6 +34,8 @@
#include "sprite_wrappers.h"
#include "modules/palettes.h"
#include "tinyxml.h"
static int new_card, new_w, new_h, new_depth, new_scaling;
static int old_card, old_w, old_h, old_depth, old_scaling;
@ -152,82 +154,78 @@ void ConfigureScreen::show_dialog(Context* context)
void ConfigureScreen::load_resolutions(JWidget resolution, JWidget color_depth, JWidget pixel_scale)
{
DIRS *dirs, *dir;
JXml xml;
char buf[512];
dirs = filename_in_datadir("usergui.xml");
{
sprintf(buf, "gui-%s.xml", intl_get_lang());
dirs_cat_dirs(dirs, filename_in_datadir(buf));
dirs_cat_dirs(dirs, filename_in_datadir("gui-en.xml"));
}
m_resolutions.clear();
m_colordepths.clear();
m_pixelscale.clear();
for (dir=dirs; dir; dir=dir->next) {
DIRS* dirs = filename_in_datadir("gui.xml");
for (DIRS* dir=dirs; dir; dir=dir->next) {
PRINTF("Trying to load screen resolutions file from \"%s\"...\n", dir->path);
// open the XML menu definition file
xml = jxml_new_from_file(dir->path);
if (xml && jxml_get_root(xml)) {
JXmlElem xml_resolutions = jxmlelem_get_elem_by_name(jxml_get_root(xml), "resolutions");
if (xml_resolutions) {
JLink link;
JI_LIST_FOR_EACH(((JXmlNode)xml_resolutions)->children, link) {
JXmlNode child = (JXmlNode)link->data;
JXmlElem elem = (JXmlElem)child;
if (strcmp(jxmlelem_get_name(elem), "screensize") == 0) {
int w = ustrtol(jxmlelem_get_attr(elem, "width"), NULL, 10);
int h = ustrtol(jxmlelem_get_attr(elem, "height"), NULL, 10);
const char* aspect = jxmlelem_get_attr(elem, "aspect");
if (!exists(dir->path))
continue;
if (w > 0 && h > 0) {
m_resolutions.push_back(std::make_pair(w, h));
PRINTF(" - \"%s\" found\n", dir->path);
if (aspect)
sprintf(buf, "%dx%d (%s)", w, h, aspect);
else
sprintf(buf, "%dx%d", w, h, aspect);
TiXmlDocument doc;
if (!doc.LoadFile(dir->path))
throw ase_exception(&doc);
jcombobox_add_string(resolution, buf, NULL);
if (old_w == w && old_h == h)
jcombobox_select_index(resolution, jcombobox_get_count(resolution)-1);
}
}
else if (strcmp(jxmlelem_get_name(elem), "colordepth") == 0) {
int bpp = ustrtol(jxmlelem_get_attr(elem, "bpp"), NULL, 10);
const char* label = jxmlelem_get_attr(elem, "label");
TiXmlHandle handle(&doc);
if (bpp > 0 && label) {
m_colordepths.push_back(bpp);
TiXmlElement* xmlElement = handle
.FirstChild("gui")
.FirstChild("resolutions")
.FirstChildElement().ToElement();
jcombobox_add_string(color_depth, label, NULL);
if (old_depth == bpp)
jcombobox_select_index(color_depth, jcombobox_get_count(color_depth)-1);
}
}
else if (strcmp(jxmlelem_get_name(elem), "pixelscale") == 0) {
int factor = ustrtol(jxmlelem_get_attr(elem, "factor"), NULL, 10);
const char* label = jxmlelem_get_attr(elem, "label");
while (xmlElement) {
if (strcmp(xmlElement->Value(), "screensize") == 0) {
int w = ustrtol(xmlElement->Attribute("width"), NULL, 10);
int h = ustrtol(xmlElement->Attribute("height"), NULL, 10);
const char* aspect = xmlElement->Attribute("aspect");
if (factor > 0 && label) {
m_pixelscale.push_back(factor);
if (w > 0 && h > 0) {
m_resolutions.push_back(std::make_pair(w, h));
jcombobox_add_string(pixel_scale, label, NULL);
if (old_scaling == factor)
jcombobox_select_index(pixel_scale, jcombobox_get_count(pixel_scale)-1);
}
}
if (aspect)
sprintf(buf, "%dx%d (%s)", w, h, aspect);
else
sprintf(buf, "%dx%d", w, h, aspect);
jcombobox_add_string(resolution, buf, NULL);
if (old_w == w && old_h == h)
jcombobox_select_index(resolution, jcombobox_get_count(resolution)-1);
}
}
else if (strcmp(xmlElement->Value(), "colordepth") == 0) {
int bpp = ustrtol(xmlElement->Attribute("bpp"), NULL, 10);
const char* label = xmlElement->Attribute("label");
if (bpp > 0 && label) {
m_colordepths.push_back(bpp);
jcombobox_add_string(color_depth, label, NULL);
if (old_depth == bpp)
jcombobox_select_index(color_depth, jcombobox_get_count(color_depth)-1);
}
}
else if (strcmp(xmlElement->Value(), "pixelscale") == 0) {
int factor = ustrtol(xmlElement->Attribute("factor"), NULL, 10);
const char* label = xmlElement->Attribute("label");
if (factor > 0 && label) {
m_pixelscale.push_back(factor);
jcombobox_add_string(pixel_scale, label, NULL);
if (old_scaling == factor)
jcombobox_select_index(pixel_scale, jcombobox_get_count(pixel_scale)-1);
}
}
// free the XML file
jxml_free(xml);
break;
xmlElement = xmlElement->NextSiblingElement();
}
}

99
src/jinete/jexception.cpp Normal file
View File

@ -0,0 +1,99 @@
/* Jinete - a GUI library
* Copyright (C) 2003-2009 David Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of the author nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <allegro.h>
#include <stdio.h>
#include "jinete/jexception.h"
#include "tinyxml.h"
jexception::jexception(const char* msg, ...) throw()
{
try {
if (!ustrchr(msg, '%')) {
m_msg = msg;
}
else {
va_list ap;
va_start(ap, msg);
char buf[1024]; // TODO warning buffer overflow
uvsprintf(buf, msg, ap);
m_msg = buf;
va_end(ap);
}
}
catch (...) {
// no throw
}
}
jexception::jexception(const std::string& msg) throw()
{
try {
m_msg = msg;
}
catch (...) {
// no throw
}
}
jexception::jexception(TiXmlDocument* doc) throw()
{
try {
char buf[1024];
usprintf(buf, "Error in XML file '%s' (line %d, column %d)\nError %d: %s",
doc->Value(), doc->ErrorRow(), doc->ErrorCol(),
doc->ErrorId(), doc->ErrorDesc());
m_msg = buf;
}
catch (...) {
// no throw
}
}
jexception::~jexception() throw()
{
}
void jexception::show()
{
allegro_message("An error occurred.\n\nDetails:\n%s", what());
}
const char* jexception::what() const throw()
{
return m_msg.c_str();
}

59
src/jinete/jexception.h Normal file
View File

@ -0,0 +1,59 @@
/* Jinete - a GUI library
* Copyright (C) 2003-2009 David Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of the author nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef JINETE_JEXCEPTION_H_INCLUDED
#define JINETE_JEXCEPTION_H_INCLUDED
#include <exception>
#include <string>
#include "jinete/jbase.h"
class TiXmlDocument;
class jexception : public std::exception
{
protected:
std::string m_msg;
public:
jexception() throw() { }
jexception(const char* msg, ...) throw();
jexception(const std::string& msg) throw();
jexception(TiXmlDocument* doc) throw();
virtual ~jexception() throw();
virtual void show();
const char* what() const throw();
};
#endif

View File

@ -40,6 +40,8 @@
#include "jinete/jinete.h"
#include "tinyxml.h"
/* determine is the characer is a blank space */
#define IS_BLANK(c) (((c) == ' ') || \
((c) == '\t') || \
@ -53,46 +55,48 @@
#define TRANSLATE_ATTR(a) a
static JWidget convert_tag_to_widget(JXmlElem elem);
static bool bool_attr_is_true(TiXmlElement* elem, const char* attribute_name);
static JWidget convert_xmlelement_to_widget(TiXmlElement* elem);
static int convert_align_value_to_flags(const char *value);
JWidget ji_load_widget(const char *filename, const char *name)
{
JWidget widget = NULL;
JXml xml;
JList children;
JLink link;
xml = jxml_new_from_file(filename);
if (!xml)
return NULL;
TiXmlDocument doc;
if (!doc.LoadFile(filename))
throw jexception(&doc);
/* search the requested widget */
children = jxml_get_root(xml)->head.children;
JI_LIST_FOR_EACH(children, link) {
JXmlNode node = reinterpret_cast<JXmlNode>(link->data);
// search the requested widget
TiXmlHandle handle(&doc);
TiXmlElement* xmlElement = handle
.FirstChild("jinete")
.FirstChildElement().ToElement();
/* if this node is an XML Element and has a "name" property... */
if (node->type == JI_XML_ELEM &&
jxmlelem_has_attr((JXmlElem)node, "name")) {
/* ...then we can compare both names (the requested one with the
element's name) */
const char *nodename = jxmlelem_get_attr((JXmlElem)node, "name");
if (nodename != NULL && ustrcmp(nodename, name) == 0) {
/* convert tags to Jinete widgets */
widget = convert_tag_to_widget((JXmlElem)node);
break;
}
while (xmlElement) {
const char* nodename = xmlElement->Attribute("name");
if (nodename && ustrcmp(nodename, name) == 0) {
widget = convert_xmlelement_to_widget(xmlElement);
break;
}
xmlElement = xmlElement->NextSiblingElement();
}
jxml_free(xml);
return widget;
}
static JWidget convert_tag_to_widget(JXmlElem elem)
static bool bool_attr_is_true(TiXmlElement* elem, const char* attribute_name)
{
const char *elem_name = jxmlelem_get_name(elem);
const char* value = elem->Attribute(attribute_name);
return (value != NULL) && (strcmp(value, "true") == 0);
}
static JWidget convert_xmlelement_to_widget(TiXmlElement* elem)
{
const char *elem_name = elem->Value();
JWidget widget = NULL;
JWidget child;
@ -100,9 +104,9 @@ static JWidget convert_tag_to_widget(JXmlElem elem)
/* box */
if (ustrcmp(elem_name, "box") == 0) {
bool horizontal = jxmlelem_has_attr(elem, "horizontal");
bool vertical = jxmlelem_has_attr(elem, "vertical");
bool homogeneous = jxmlelem_has_attr(elem, "homogeneous");
bool horizontal = bool_attr_is_true(elem, "horizontal");
bool vertical = bool_attr_is_true(elem, "vertical");
bool homogeneous = bool_attr_is_true(elem, "homogeneous");
widget = jbox_new((horizontal ? JI_HORIZONTAL:
vertical ? JI_VERTICAL: 0) |
@ -110,15 +114,15 @@ static JWidget convert_tag_to_widget(JXmlElem elem)
}
/* button */
else if (ustrcmp(elem_name, "button") == 0) {
const char *text = jxmlelem_get_attr(elem, "text");
const char *text = elem->Attribute("text");
widget = jbutton_new(text ? TRANSLATE_ATTR(text): NULL);
if (widget) {
bool left = jxmlelem_has_attr(elem, "left");
bool right = jxmlelem_has_attr(elem, "right");
bool top = jxmlelem_has_attr(elem, "top");
bool bottom = jxmlelem_has_attr(elem, "bottom");
const char *_bevel = jxmlelem_get_attr(elem, "bevel");
bool left = bool_attr_is_true(elem, "left");
bool right = bool_attr_is_true(elem, "right");
bool top = bool_attr_is_true(elem, "top");
bool bottom = bool_attr_is_true(elem, "bottom");
const char *_bevel = elem->Attribute("bevel");
jwidget_set_align(widget,
(left ? JI_LEFT: (right ? JI_RIGHT: JI_CENTER)) |
@ -146,14 +150,14 @@ static JWidget convert_tag_to_widget(JXmlElem elem)
}
/* check */
else if (ustrcmp(elem_name, "check") == 0) {
const char *text = jxmlelem_get_attr(elem, "text");
const char *text = elem->Attribute("text");
widget = jcheck_new(text ? TRANSLATE_ATTR(text): NULL);
if (widget) {
bool center = jxmlelem_has_attr(elem, "center");
bool right = jxmlelem_has_attr(elem, "right");
bool top = jxmlelem_has_attr(elem, "top");
bool bottom = jxmlelem_has_attr(elem, "bottom");
bool center = bool_attr_is_true(elem, "center");
bool right = bool_attr_is_true(elem, "right");
bool top = bool_attr_is_true(elem, "top");
bool bottom = bool_attr_is_true(elem, "bottom");
jwidget_set_align(widget,
(center ? JI_CENTER:
@ -168,11 +172,11 @@ static JWidget convert_tag_to_widget(JXmlElem elem)
}
/* entry */
else if (ustrcmp(elem_name, "entry") == 0) {
const char *maxsize = jxmlelem_get_attr(elem, "maxsize");
const char *text = jxmlelem_get_attr(elem, "text");
const char *maxsize = elem->Attribute("maxsize");
const char *text = elem->Attribute("text");
if (maxsize != NULL) {
bool readonly = jxmlelem_has_attr(elem, "readonly");
bool readonly = bool_attr_is_true(elem, "readonly");
widget = jentry_new(ustrtol(maxsize, NULL, 10),
text ? TRANSLATE_ATTR(text): NULL);
@ -183,8 +187,8 @@ static JWidget convert_tag_to_widget(JXmlElem elem)
}
/* grid */
else if (ustrcmp(elem_name, "grid") == 0) {
const char *columns = jxmlelem_get_attr(elem, "columns");
bool same_width_columns = jxmlelem_has_attr(elem, "same_width_columns");
const char *columns = elem->Attribute("columns");
bool same_width_columns = bool_attr_is_true(elem, "same_width_columns");
if (columns != NULL) {
widget = jgrid_new(ustrtol(columns, NULL, 10),
@ -193,14 +197,14 @@ static JWidget convert_tag_to_widget(JXmlElem elem)
}
/* label */
else if (ustrcmp(elem_name, "label") == 0) {
const char *text = jxmlelem_get_attr(elem, "text");
const char *text = elem->Attribute("text");
widget = jlabel_new(text ? TRANSLATE_ATTR(text): NULL);
if (widget) {
bool center = jxmlelem_has_attr(elem, "center");
bool right = jxmlelem_has_attr(elem, "right");
bool top = jxmlelem_has_attr(elem, "top");
bool bottom = jxmlelem_has_attr(elem, "bottom");
bool center = bool_attr_is_true(elem, "center");
bool right = bool_attr_is_true(elem, "right");
bool top = bool_attr_is_true(elem, "top");
bool bottom = bool_attr_is_true(elem, "bottom");
jwidget_set_align(widget,
(center ? JI_CENTER:
@ -215,30 +219,30 @@ static JWidget convert_tag_to_widget(JXmlElem elem)
}
/* listitem */
else if (ustrcmp(elem_name, "listitem") == 0) {
const char *text = jxmlelem_get_attr(elem, "text");
const char *text = elem->Attribute("text");
widget = jlistitem_new(text ? TRANSLATE_ATTR(text): NULL);
}
/* panel */
else if (ustrcmp(elem_name, "panel") == 0) {
bool horizontal = jxmlelem_has_attr(elem, "horizontal");
bool vertical = jxmlelem_has_attr(elem, "vertical");
bool horizontal = bool_attr_is_true(elem, "horizontal");
bool vertical = bool_attr_is_true(elem, "vertical");
widget = jpanel_new(horizontal ? JI_HORIZONTAL:
vertical ? JI_VERTICAL: 0);
}
/* radio */
else if (ustrcmp(elem_name, "radio") == 0) {
const char *text = jxmlelem_get_attr(elem, "text");
const char *group = jxmlelem_get_attr(elem, "group");
const char* text = elem->Attribute("text");
const char* group = elem->Attribute("group");
widget = jradio_new(text ? TRANSLATE_ATTR(text): NULL,
group ? ustrtol(group, NULL, 10): 1);
if (widget) {
bool center = jxmlelem_has_attr(elem, "center");
bool right = jxmlelem_has_attr(elem, "right");
bool top = jxmlelem_has_attr(elem, "top");
bool bottom = jxmlelem_has_attr(elem, "bottom");
bool center = bool_attr_is_true(elem, "center");
bool right = bool_attr_is_true(elem, "right");
bool top = bool_attr_is_true(elem, "top");
bool bottom = bool_attr_is_true(elem, "bottom");
jwidget_set_align(widget,
(center ? JI_CENTER:
@ -249,13 +253,13 @@ static JWidget convert_tag_to_widget(JXmlElem elem)
}
/* separator */
else if (ustrcmp(elem_name, "separator") == 0) {
const char *text = jxmlelem_get_attr(elem, "text");
bool center = jxmlelem_has_attr(elem, "center");
bool right = jxmlelem_has_attr(elem, "right");
bool middle = jxmlelem_has_attr(elem, "middle");
bool bottom = jxmlelem_has_attr(elem, "bottom");
bool horizontal = jxmlelem_has_attr(elem, "horizontal");
bool vertical = jxmlelem_has_attr(elem, "vertical");
const char *text = elem->Attribute("text");
bool center = bool_attr_is_true(elem, "center");
bool right = bool_attr_is_true(elem, "right");
bool middle = bool_attr_is_true(elem, "middle");
bool bottom = bool_attr_is_true(elem, "bottom");
bool horizontal = bool_attr_is_true(elem, "horizontal");
bool vertical = bool_attr_is_true(elem, "vertical");
widget = ji_separator_new(text ? TRANSLATE_ATTR(text): NULL,
(horizontal ? JI_HORIZONTAL: 0) |
@ -267,8 +271,8 @@ static JWidget convert_tag_to_widget(JXmlElem elem)
}
/* slider */
else if (ustrcmp(elem_name, "slider") == 0) {
const char *min = jxmlelem_get_attr(elem, "min");
const char *max = jxmlelem_get_attr(elem, "max");
const char *min = elem->Attribute("min");
const char *max = elem->Attribute("max");
int min_value = min != NULL ? ustrtol(min, NULL, 10): 0;
int max_value = max != NULL ? ustrtol(max, NULL, 10): 0;
@ -276,7 +280,7 @@ static JWidget convert_tag_to_widget(JXmlElem elem)
}
/* textbox */
else if (ustrcmp(elem_name, "textbox") == 0) {
bool wordwrap = jxmlelem_has_attr(elem, "wordwrap");
bool wordwrap = bool_attr_is_true(elem, "wordwrap");
/* TODO add translatable support */
/* TODO here we need jxmlelem_get_text(elem) */
@ -289,10 +293,10 @@ static JWidget convert_tag_to_widget(JXmlElem elem)
}
/* window */
else if (ustrcmp(elem_name, "window") == 0) {
const char *text = jxmlelem_get_attr(elem, "text");
const char *text = elem->Attribute("text");
if (text) {
bool desktop = jxmlelem_has_attr(elem, "desktop");
bool desktop = bool_attr_is_true(elem, "desktop");
if (desktop)
widget = jwindow_new_desktop();
@ -303,20 +307,19 @@ static JWidget convert_tag_to_widget(JXmlElem elem)
/* the widget was created? */
if (widget) {
const char *name = jxmlelem_get_attr(elem, "name");
const char *tooltip = jxmlelem_get_attr(elem, "tooltip");
bool selected = jxmlelem_has_attr(elem, "selected");
bool expansive = jxmlelem_has_attr(elem, "expansive");
bool magnetic = jxmlelem_has_attr(elem, "magnetic");
bool noborders = jxmlelem_has_attr(elem, "noborders");
const char *width = jxmlelem_get_attr(elem, "width");
const char *height = jxmlelem_get_attr(elem, "height");
const char *minwidth = jxmlelem_get_attr(elem, "minwidth");
const char *minheight = jxmlelem_get_attr(elem, "minheight");
const char *maxwidth = jxmlelem_get_attr(elem, "maxwidth");
const char *maxheight = jxmlelem_get_attr(elem, "maxheight");
const char *childspacing = jxmlelem_get_attr(elem, "childspacing");
JLink link;
const char *name = elem->Attribute("name");
const char *tooltip = elem->Attribute("tooltip");
bool selected = bool_attr_is_true(elem, "selected");
bool expansive = bool_attr_is_true(elem, "expansive");
bool magnetic = bool_attr_is_true(elem, "magnetic");
bool noborders = bool_attr_is_true(elem, "noborders");
const char *width = elem->Attribute("width");
const char *height = elem->Attribute("height");
const char *minwidth = elem->Attribute("minwidth");
const char *minheight = elem->Attribute("minheight");
const char *maxwidth = elem->Attribute("maxwidth");
const char *maxheight = elem->Attribute("maxheight");
const char *childspacing = elem->Attribute("childspacing");
if (name != NULL)
jwidget_set_name(widget, name);
@ -351,37 +354,35 @@ static JWidget convert_tag_to_widget(JXmlElem elem)
}
/* children */
JI_LIST_FOR_EACH(elem->head.children, link) {
if (((JXmlNode)link->data)->type == JI_XML_ELEM) {
JXmlElem child_elem = (JXmlElem)link->data;
child = convert_tag_to_widget(child_elem);
if (child != NULL) {
/* attach the child in the view */
if (widget->type == JI_VIEW) {
jview_attach(widget, child);
break;
}
/* add the child in the grid */
else if (widget->type == JI_GRID) {
const char *cell_hspan = jxmlelem_get_attr(child_elem, "cell_hspan");
const char *cell_vspan = jxmlelem_get_attr(child_elem, "cell_vspan");
const char *cell_align = jxmlelem_get_attr(child_elem, "cell_align");
int hspan = cell_hspan ? ustrtol(cell_hspan, NULL, 10): 1;
int vspan = cell_vspan ? ustrtol(cell_vspan, NULL, 10): 1;
int align = cell_align ? convert_align_value_to_flags(cell_align): 0;
jgrid_add_child(widget, child, hspan, vspan, align);
}
/* just add the child in any other kind of widget */
else
jwidget_add_child(widget, child);
TiXmlElement* child_elem = elem->FirstChildElement();
while (child_elem) {
child = convert_xmlelement_to_widget(child_elem);
if (child) {
/* attach the child in the view */
if (widget->type == JI_VIEW) {
jview_attach(widget, child);
break;
}
/* add the child in the grid */
else if (widget->type == JI_GRID) {
const char* cell_hspan = child_elem->Attribute("cell_hspan");
const char* cell_vspan = child_elem->Attribute("cell_vspan");
const char* cell_align = child_elem->Attribute("cell_align");
int hspan = cell_hspan ? ustrtol(cell_hspan, NULL, 10): 1;
int vspan = cell_vspan ? ustrtol(cell_vspan, NULL, 10): 1;
int align = cell_align ? convert_align_value_to_flags(cell_align): 0;
jgrid_add_child(widget, child, hspan, vspan, align);
}
/* just add the child in any other kind of widget */
else
jwidget_add_child(widget, child);
}
child_elem = child_elem->NextSiblingElement();
}
if (widget->type == JI_VIEW) {
bool maxsize = jxmlelem_has_attr(elem, "maxsize");
bool maxsize = bool_attr_is_true(elem, "maxsize");
if (maxsize)
jview_maxsize(widget);
}

View File

@ -42,6 +42,7 @@
#include "jinete/jdraw.h"
#include "jinete/jentry.h"
#include "jinete/jgrid.h"
#include "jinete/jexception.h"
#include "jinete/jfile.h"
#include "jinete/jfilesel.h"
#include "jinete/jfont.h"

View File

@ -59,7 +59,7 @@ public:
/**
* Here ASE starts.
*/
int main(int argc, char *argv[])
int main(int argc, char* argv[])
{
int status = 1; // 1 = error
try {
@ -70,6 +70,9 @@ int main(int argc, char *argv[])
status = app.run();
}
catch (jexception& e) {
e.show();
}
catch (std::exception& e) {
allegro_message(e.what());
}

View File

@ -21,6 +21,7 @@
#include <stdio.h>
#include <string.h>
#include <allegro/unicode.h>
#include <allegro/file.h>
#include "jinete/jinete.h"
@ -38,6 +39,8 @@
#include "util/filetoks.h"
#include "widgets/menuitem.h"
#include "tinyxml.h"
static JWidget root_menu;
static JWidget recent_list_menuitem;
@ -45,12 +48,11 @@ static JWidget layer_popup_menu;
static JWidget frame_popup_menu;
static JWidget cel_popup_menu;
static JWidget cel_movement_popup_menu;
static JWidget filters_popup_menu;
static int load_root_menu();
static JWidget load_menu_by_id(JXml xml, const char *id, const char *filename);
static JWidget convert_xmlelem_to_menu(JXmlElem elem);
static JWidget convert_xmlelem_to_menuitem(JXmlElem elem);
static JWidget load_menu_by_id(TiXmlHandle& handle, const char *id);
static JWidget convert_xmlelem_to_menu(TiXmlElement* elem);
static JWidget convert_xmlelem_to_menuitem(TiXmlElement* elem);
static void apply_shortcut_to_menuitems_with_command(JWidget menu, Command* command, Params* params, JAccel accel);
int init_module_rootmenu()
@ -60,7 +62,6 @@ int init_module_rootmenu()
frame_popup_menu = NULL;
cel_popup_menu = NULL;
cel_movement_popup_menu = NULL;
filters_popup_menu = NULL;
recent_list_menuitem = NULL;
return load_root_menu();
@ -68,13 +69,11 @@ int init_module_rootmenu()
void exit_module_rootmenu()
{
jwidget_free(root_menu);
if (layer_popup_menu) jwidget_free(layer_popup_menu);
if (frame_popup_menu) jwidget_free(frame_popup_menu);
if (cel_popup_menu) jwidget_free(cel_popup_menu);
if (cel_movement_popup_menu) jwidget_free(cel_movement_popup_menu);
if (filters_popup_menu) jwidget_free(filters_popup_menu);
delete root_menu;
delete layer_popup_menu;
delete frame_popup_menu;
delete cel_popup_menu;
delete cel_movement_popup_menu;
}
JWidget get_root_menu() { return root_menu; }
@ -85,23 +84,8 @@ JWidget get_frame_popup_menu() { return frame_popup_menu; }
JWidget get_cel_popup_menu() { return cel_popup_menu; }
JWidget get_cel_movement_popup_menu() { return cel_movement_popup_menu; }
/* void show_fx_popup_menu() */
/* { */
/* if (is_interactive() && */
/* filters_popup_menuitem && */
/* jmenuitem_get_submenu(filters_popup_menuitem)) { */
/* jmenu_popup(jmenuitem_get_submenu(filters_popup_menuitem), */
/* jmouse_x(0), jmouse_y(0)); */
/* } */
/* } */
static int load_root_menu()
{
DIRS *dirs, *dir;
JLink link;
JXml xml;
JXmlElem child;
if (app_get_menubar())
jmenubar_set_menu(app_get_menubar(), NULL);
@ -116,140 +100,119 @@ static int load_root_menu()
frame_popup_menu = NULL;
cel_popup_menu = NULL;
cel_movement_popup_menu = NULL;
filters_popup_menu = NULL;
dirs = filename_in_datadir("usergui.xml");
{
char buf[256];
sprintf(buf, "gui-%s.xml", intl_get_lang());
dirs_cat_dirs(dirs, filename_in_datadir(buf));
dirs_cat_dirs(dirs, filename_in_datadir("gui-en.xml"));
}
DIRS* dirs = filename_in_datadir("gui.xml");
for (dir=dirs; dir; dir=dir->next) {
for (DIRS* dir=dirs; dir; dir=dir->next) {
PRINTF("Trying to load GUI definition file from \"%s\"...\n", dir->path);
if (!exists(dir->path))
continue;
PRINTF(" - \"%s\" found\n", dir->path);
/* open the XML menu definition file */
xml = jxml_new_from_file(dir->path);
if (xml && jxml_get_root(xml)) {
/**************************************************/
/* load menus */
/**************************************************/
TiXmlDocument doc;
if (!doc.LoadFile(dir->path))
throw ase_exception(&doc);
PRINTF("Trying to menus from \"%s\"...\n", dir->path);
TiXmlHandle handle(&doc);
root_menu = load_menu_by_id(xml, "main_menu", dir->path);
if (!root_menu) {
PRINTF("Error loading \"main_menu\" from \"%s\" file.\n", dir->path);
return -1;
}
/**************************************************/
/* load menus */
/**************************************************/
layer_popup_menu = load_menu_by_id(xml, "layer_popup", dir->path);
frame_popup_menu = load_menu_by_id(xml, "frame_popup", dir->path);
cel_popup_menu = load_menu_by_id(xml, "cel_popup", dir->path);
cel_movement_popup_menu = load_menu_by_id(xml, "cel_movement_popup", dir->path);
filters_popup_menu = load_menu_by_id(xml, "filters_popup", dir->path);
PRINTF(" - Loading menus from \"%s\"...\n", dir->path);
/**************************************************/
/* load keyboard shortcuts for commands */
/**************************************************/
root_menu = load_menu_by_id(handle, "main_menu");
if (!root_menu)
throw ase_exception("Error loading main menu from file:\n%s\nReinstall the application.",
static_cast<const char*>(dir->path));
PRINTF("Loading commands shortcuts from \"%s\"...\n", dir->path);
layer_popup_menu = load_menu_by_id(handle, "layer_popup");
frame_popup_menu = load_menu_by_id(handle, "frame_popup");
cel_popup_menu = load_menu_by_id(handle, "cel_popup");
cel_movement_popup_menu = load_menu_by_id(handle, "cel_movement_popup");
/* find the <keyboard> element */
child = jxmlelem_get_elem_by_name(jxml_get_root(xml), "keyboard");
if (child != NULL) {
/* find the <menus> element */
child = jxmlelem_get_elem_by_name(child, "commands");
if (child != NULL) {
/* for each children in <keyboard><commands>...</commands></keyboard> */
JI_LIST_FOR_EACH(child->head.children, link) {
JXmlNode child2 = (JXmlNode)link->data;
/**************************************************/
/* load keyboard shortcuts for commands */
/**************************************************/
/* it is a <key> element? */
if (child2->type == JI_XML_ELEM &&
strcmp(jxmlelem_get_name((JXmlElem)child2), "key") == 0) {
/* finally, we can read the <key /> */
const char *command_name = jxmlelem_get_attr((JXmlElem)child2, "command");
const char *command_key = jxmlelem_get_attr((JXmlElem)child2, "shortcut");
PRINTF(" - Loading commands keyboard shortcuts from \"%s\"...\n", dir->path);
if (command_name && command_key) {
Command *command = CommandsModule::instance()->get_command_by_name(command_name);
if (command) {
// Read params
Params params;
{
JLink link3;
JI_LIST_FOR_EACH(((JXmlElem)child2)->head.children, link3) {
JXmlNode child3 = (JXmlNode)link3->data;
// <gui><keyboard><commands><key>
TiXmlElement* xmlKey = handle
.FirstChild("gui")
.FirstChild("keyboard")
.FirstChild("commands")
.FirstChild("key").ToElement();
while (xmlKey) {
const char* command_name = xmlKey->Attribute("command");
const char* command_key = xmlKey->Attribute("shortcut");
if (child3->type == JI_XML_ELEM &&
strcmp(jxmlelem_get_name((JXmlElem)child3), "param") == 0) {
const char* param_name = jxmlelem_get_attr((JXmlElem)child3, "name");
const char* param_value = jxmlelem_get_attr((JXmlElem)child3, "value");
params.set(param_name, param_value);
}
}
}
if (command_name && command_key) {
Command *command = CommandsModule::instance()->get_command_by_name(command_name);
if (command) {
// Read params
Params params;
bool first_shortcut =
(get_accel_to_execute_command(command_name, &params) == NULL);
TiXmlElement* xmlParam = xmlKey->FirstChildElement("param");
while (xmlParam) {
const char* param_name = xmlParam->Attribute("name");
const char* param_value = xmlParam->Attribute("value");
PRINTF("- Shortcut for command `%s' <%s>\n", command_name, command_key);
if (param_name && param_value)
params.set(param_name, param_value);
xmlParam = xmlParam->NextSiblingElement();
}
bool first_shortcut =
(get_accel_to_execute_command(command_name, &params) == NULL);
PRINTF(" - Shortcut for command `%s' <%s>\n", command_name, command_key);
// add the keyboard shortcut to the command
JAccel accel =
add_keyboard_shortcut_to_execute_command(command_key, command_name, &params);
// add the keyboard shortcut to the command
JAccel accel =
add_keyboard_shortcut_to_execute_command(command_key, command_name, &params);
// add the shortcut to the menuitems with this
// command (this is only visual, the "manager_msg_proc"
// is the only one that process keyboard shortcuts)
if (first_shortcut)
apply_shortcut_to_menuitems_with_command(root_menu, command, &params, accel);
}
}
}
}
// add the shortcut to the menuitems with this
// command (this is only visual, the "manager_msg_proc"
// is the only one that process keyboard shortcuts)
if (first_shortcut)
apply_shortcut_to_menuitems_with_command(root_menu, command, &params, accel);
}
}
/**************************************************/
/* load keyboard shortcuts for tools */
/**************************************************/
xmlKey = xmlKey->NextSiblingElement();
}
PRINTF("Loading tools shortcuts from \"%s\"...\n", dir->path);
/**************************************************/
/* load keyboard shortcuts for tools */
/**************************************************/
/* find the <keyboard> element */
child = jxmlelem_get_elem_by_name(jxml_get_root(xml), "keyboard");
if (child != NULL) {
/* find the <tools> element */
child = jxmlelem_get_elem_by_name(child, "tools");
if (child != NULL) {
/* for each children in <keyboard><tools>...</tools></keyboard> */
JI_LIST_FOR_EACH(child->head.children, link) {
JXmlNode child2 = (JXmlNode)link->data;
PRINTF(" - Loading tools keyboard shortcuts from \"%s\"...\n", dir->path);
/* it is a <key> element? */
if (child2->type == JI_XML_ELEM &&
strcmp(jxmlelem_get_name((JXmlElem)child2), "key") == 0) {
/* finally, we can read the <key /> */
const char *tool_name = jxmlelem_get_attr((JXmlElem)child2, "tool");
const char *tool_key = jxmlelem_get_attr((JXmlElem)child2, "shortcut");
if (tool_name && tool_key) {
Tool *tool = get_tool_by_name(tool_name);
if (tool) {
/* add the keyboard shortcut to the tool */
PRINTF("- Shortcut for tool `%s': <%s>\n", tool_name, tool_key);
add_keyboard_shortcut_to_change_tool(tool_key, tool);
}
}
}
}
// <gui><keyboard><tools><key>
xmlKey = handle
.FirstChild("gui")
.FirstChild("keyboard")
.FirstChild("tools")
.FirstChild("key").ToElement();
while (xmlKey) {
const char* tool_id = xmlKey->Attribute("tool");
const char* tool_key = xmlKey->Attribute("shortcut");
if (tool_id && tool_key) {
Tool *tool = get_tool_by_name(tool_id);
if (tool) {
/* add the keyboard shortcut to the tool */
PRINTF(" - Shortcut for tool `%s': <%s>\n", tool_id, tool_key);
add_keyboard_shortcut_to_change_tool(tool_key, tool);
}
}
/* free the XML file */
jxml_free(xml);
xmlKey = xmlKey->NextSiblingElement();
}
if (root_menu) {
@ -260,11 +223,9 @@ static int load_root_menu()
dirs_free(dirs);
/* no menus? */
if (!root_menu) {
user_printf(_("Error loading main menu\n"));
return -1;
}
// no menus
if (!root_menu)
throw ase_exception("Error loading main menu\n");
/* sets the "menu" of the "menu-bar" to the new "root-menu" */
if (app_get_menubar()) {
@ -276,112 +237,98 @@ static int load_root_menu()
return 0;
}
static JWidget load_menu_by_id(JXml xml, const char *id, const char *filename)
static JWidget load_menu_by_id(TiXmlHandle& handle, const char* id)
{
JWidget menu = NULL;
JXmlElem elem;
assert(id != NULL);
/* get the <menu> element with the specified id */
elem = jxml_get_elem_by_id(xml, id);
if (elem) {
/* is it a <menu> element? */
if (strcmp(jxmlelem_get_name(elem), "menu") == 0) {
/* ok, convert it to a menu JWidget */
menu = convert_xmlelem_to_menu(elem);
}
else
PRINTF("Invalid element with id=\"%s\" in \"%s\"\n", id, filename);
}
else
PRINTF("\"%s\" element couldn't be found...\n", id);
//PRINTF("load_menu_by_id(%s)\n", id);
return menu;
// <gui><menus><menu>
TiXmlElement* xmlMenu = handle
.FirstChild("gui")
.FirstChild("menus")
.FirstChild("menu").ToElement();
while (xmlMenu) {
const char* menu_id = xmlMenu->Attribute("id");
if (menu_id && strcmp(menu_id, id) == 0)
return convert_xmlelem_to_menu(xmlMenu);
xmlMenu = xmlMenu->NextSiblingElement();
}
PRINTF(" - \"%s\" element was not found\n", id);
return NULL;
}
static JWidget convert_xmlelem_to_menu(JXmlElem elem)
static JWidget convert_xmlelem_to_menu(TiXmlElement* elem)
{
JWidget menu = jmenu_new();
JWidget menuitem;
JLink link;
JI_LIST_FOR_EACH(((JXmlNode)elem)->children, link) {
JXmlNode child = (JXmlNode)link->data;
//PRINTF("convert_xmlelem_to_menu(%s, %s, %s)\n", elem->Value(), elem->Attribute("id"), elem->Attribute("text"));
/* PRINTF("convert_xmlelem_to_menu: child->value = %p (%s)\n", */
/* child->value, child->value ? child->value: ""); */
TiXmlElement* child = elem->FirstChildElement();
while (child) {
JWidget menuitem = convert_xmlelem_to_menuitem(child);
if (menuitem)
jwidget_add_child(menu, menuitem);
else
throw ase_exception("Error converting the element \"%s\" to a menu-item.\n",
static_cast<const char*>(child->Value()));
if (child->type == JI_XML_ELEM) {
menuitem = convert_xmlelem_to_menuitem((JXmlElem)child);
if (menuitem)
jwidget_add_child(menu, menuitem);
else {
PRINTF("Error converting the element \"%s\" to a menu-item.\n",
jxmlelem_get_name((JXmlElem)child));
return NULL;
}
}
child = child->NextSiblingElement();
}
return menu;
}
static JWidget convert_xmlelem_to_menuitem(JXmlElem elem)
static JWidget convert_xmlelem_to_menuitem(TiXmlElement* elem)
{
JWidget menuitem;
const char *id;
/* is it a separator? */
if (strcmp(jxmlelem_get_name(elem), "separator") == 0)
// is it a <separator>?
if (strcmp(elem->Value(), "separator") == 0)
return ji_separator_new(NULL, JI_HORIZONTAL);
const char* command_name = jxmlelem_get_attr(elem, "command");
Command* command =
const char* command_name = elem->Attribute("command");
Command* command =
command_name ? CommandsModule::instance()->get_command_by_name(command_name):
NULL;
// load params
Params params;
if (command) {
JLink link3;
JI_LIST_FOR_EACH(((JXmlElem)elem)->head.children, link3) {
JXmlNode child3 = (JXmlNode)link3->data;
TiXmlElement* xmlParam = elem->FirstChildElement("param");
while (xmlParam) {
const char* param_name = xmlParam->Attribute("name");
const char* param_value = xmlParam->Attribute("value");
if (child3->type == JI_XML_ELEM &&
strcmp(jxmlelem_get_name((JXmlElem)child3), "param") == 0) {
const char* param_name = jxmlelem_get_attr((JXmlElem)child3, "name");
const char* param_value = jxmlelem_get_attr((JXmlElem)child3, "value");
if (param_name && param_value)
params.set(param_name, param_value);
}
xmlParam = xmlParam->NextSiblingElement();
}
}
/* create the item */
menuitem = menuitem_new(jxmlelem_get_attr(elem, "name"),
command, command ? &params: NULL);
JWidget menuitem = menuitem_new(elem->Attribute("text"),
command, command ? &params: NULL);
if (!menuitem)
return NULL;
/* has it a ID? */
id = jxmlelem_get_attr(elem, "id");
if (id != NULL) {
const char* id = elem->Attribute("id");
if (id) {
/* recent list menu */
if (strcmp(id, "recent_list") == 0) {
recent_list_menuitem = menuitem;
}
}
/* has it a sub-menu? */
if (strcmp(jxmlelem_get_name(elem), "menu") == 0) {
JWidget sub_menu;
/* has it a sub-menu (<menu>)? */
if (strcmp(elem->Value(), "menu") == 0) {
/* create the sub-menu */
sub_menu = convert_xmlelem_to_menu(elem);
if (!sub_menu) {
PRINTF("Error reading the sub-menu\n");
return menuitem;
}
JWidget sub_menu = convert_xmlelem_to_menu(elem);
if (!sub_menu)
throw ase_exception("Error reading the sub-menu\n");
jmenuitem_set_submenu(menuitem, sub_menu);
}

View File

@ -43,6 +43,7 @@
#include "widgets/statebar.h"
#include "sprite_wrappers.h"
#include "ui_context.h"
#include "console.h"
#define COLORBAR_MAX_COLORS 256