diff --git a/configure.in b/configure.in index 89ab36cea..72bace0ea 100644 --- a/configure.in +++ b/configure.in @@ -45,17 +45,6 @@ if test "x$with_guile" = "xyes"; then fi dnl ----------------------- -dnl --- NEW_UI --- -AC_ARG_WITH([new-ui], - AC_HELP_STRING([--with-new-ui], [Enable New User Interface (default: no)]),, - with_new_ui="no") -NEWUI_CFLAGS= -if test "x$with_new_ui" = "xyes"; then - NEWUI_CFLAGS="-DNEW_UI" -fi -AC_SUBST(NEWUI_CFLAGS) -dnl ----------------------- - dnl --- CHECK FOR WITH SOUND --- AC_ARG_ENABLE(sound, [ --enable-sound [Use sound (default: yes)]], SOUND="$with_sound") diff --git a/doc/ChangeLog.html b/doc/ChangeLog.html index e460ca06a..22260bf72 100644 --- a/doc/ChangeLog.html +++ b/doc/ChangeLog.html @@ -36,6 +36,7 @@ <li>Future 2.00 Release<p> <ul> <li>++ + <li>NEW_UI: Giving it up, removed #ifdef, saved patch in contrib/ (from Martin Renold). <li>Removed NEW_SHIPS (from Martin Renold). <li>Allowing minimap transparency for undiscovered areas (from Martin Renold). <li>Fixed Sync bug, qsort must return a unique answer, regardless of sort order (from Russell Smith and Jimmy Salmon). diff --git a/doc/scripts/index.html b/doc/scripts/index.html index ab4628245..daa1dce4a 100644 --- a/doc/scripts/index.html +++ b/doc/scripts/index.html @@ -78,8 +78,6 @@ <dd></dd> <dt><a href="triggers.html#action-wait">action-wait</a></dt> <dd></dd> -<dt><a href="ui.html#add-button">add-button</a></dt> -<dd></dd> <dt><a href="game.html#add-keystroke-help">add-keystroke-help</a></dt> <dd></dd> <dt><a href="game.html#add-message">add-message</a></dt> @@ -138,50 +136,8 @@ <dd></dd> <dt><a href="game.html#change-units-owner">change-units-owner</a></dt> <dd></dd> -<dt><a href="ui.html#check-allowed">check-allowed</a></dt> -<dd></dd> <dt><a href="research.html#check-dependency">check-dependency</a></dt> <dd></dd> -<dt><a href="ui.html#command-attack">command-attack</a></dt> -<dd></dd> -<dt><a href="ui.html#command-attack-ground">command-attack-ground</a></dt> -<dd></dd> -<dt><a href="ui.html#command-build">command-build</a></dt> -<dd></dd> -<dt><a href="ui.html#command-cancel">command-cancel</a></dt> -<dd></dd> -<dt><a href="ui.html#command-cancel-building">command-cancel-building</a></dt> -<dd></dd> -<dt><a href="ui.html#command-cancel-train-unit">command-cancel-train-unit</a></dt> -<dd></dd> -<dt><a href="ui.html#command-cancel-upgrade">command-cancel-upgrade</a></dt> -<dd></dd> -<dt><a href="ui.html#command-cast-spell">command-cast-spell</a></dt> -<dd></dd> -<dt><a href="ui.html#command-demolish">command-demolish</a></dt> -<dd></dd> -<dt><a href="ui.html#command-harvest">command-harvest</a></dt> -<dd></dd> -<dt><a href="ui.html#command-move">command-move</a></dt> -<dd></dd> -<dt><a href="ui.html#command-patrol">command-patrol</a></dt> -<dd></dd> -<dt><a href="ui.html#command-repair">command-repair</a></dt> -<dd></dd> -<dt><a href="ui.html#command-research">command-research</a></dt> -<dd></dd> -<dt><a href="ui.html#command-return-goods">command-return-goods</a></dt> -<dd></dd> -<dt><a href="ui.html#command-stand-ground">command-stand-ground</a></dt> -<dd></dd> -<dt><a href="ui.html#command-stop">command-stop</a></dt> -<dd></dd> -<dt><a href="ui.html#command-train-unit">command-train-unit</a></dt> -<dd></dd> -<dt><a href="ui.html#command-unload">command-unload</a></dt> -<dd></dd> -<dt><a href="ui.html#command-upgrade-to">command-upgrade-to</a></dt> -<dd></dd> <dt><a href="game.html#create-unit">create-unit</a></dt> <dd></dd> <dt><a href="game.html#credits">credits</a></dt> @@ -202,6 +158,8 @@ <dd></dd> <dt><a href="game.html#define-burning-building">define-burning-building</a></dt> <dd></dd> +<dt><a href="ui.html#define-button">define-button</a></dt> +<dd></dd> <dt><a href="game.html#define-campaign">define-campaign</a></dt> <dd></dd> <dt><a href="game.html#define-construction">define-construction</a></dt> @@ -270,8 +228,6 @@ <dd></dd> <dt><a href="game.html#game-cycle">game-cycle</a></dt> <dd></dd> -<dt><a href="ui.html#get-cost-string">get-cost-string</a></dt> -<dd></dd> <dt><a href="research.html#get-dependency">get-dependency</a></dt> <dd></dd> <dt><a href="game.html#get-player-resource">get-player-resource</a></dt> @@ -360,10 +316,6 @@ <dd></dd> <dt><a href="ui.html#process-menu">process-menu</a></dt> <dd></dd> -<dt><a href="ui.html#remove-all-buttons">remove-all-buttons</a></dt> -<dd></dd> -<dt><a href="ui.html#remove-button">remove-button</a></dt> -<dd></dd> <dt><a href="game.html#remove-objective">remove-objective</a></dt> <dd></dd> <dt><a href="game.html#replay-log">replay-log</a></dt> @@ -376,26 +328,6 @@ <dd></dd> <dt><a href="config.html#right-button-moves">right-button-moves</a></dt> <dd></dd> -<dt><a href="ui.html#selected-draw-buttons">selected-draw-buttons</a></dt> -<dd></dd> -<dt><a href="ui.html#selected-get-action">selected-get-action</a></dt> -<dd></dd> -<dt><a href="ui.html#selected-get-race">selected-get-race</a></dt> -<dd></dd> -<dt><a href="ui.html#selected-get-speed">selected-get-speed</a></dt> -<dd></dd> -<dt><a href="ui.html#selected-is-building">selected-is-building</a></dt> -<dd></dd> -<dt><a href="ui.html#selected-is-training">selected-is-training</a></dt> -<dd></dd> -<dt><a href="ui.html#selected-is-upgrading">selected-is-upgrading</a></dt> -<dd></dd> -<dt><a href="ui.html#selected-mixed-units">selected-mixed-units</a></dt> -<dd></dd> -<dt><a href="ui.html#selected-owned-by-player">selected-owned-by-player</a></dt> -<dd></dd> -<dt><a href="ui.html#selected-resource-loaded">selected-resource-loaded</a></dt> -<dd></dd> <dt><a href="game.html#selection">selection</a></dt> <dd></dd> <dt><a href="config.html#set-all-players-building-limit!">set-all-players-building-limit!</a></dt> @@ -412,9 +344,7 @@ <dd></dd> <dt><a href="sound.html#set-cd-mode!">set-cd-mode!</a></dt> <dd></dd> -<dt><a href="ui.html#set-choose-target-begin-hook">set-choose-target-begin-hook</a></dt> -<dd></dd> -<dt><a href="ui.html#set-choose-target-finish-hook">set-choose-target-finish-hook</a></dt> +<dt><a href="config.html#set-click-missile!">set-click-missile!</a></dt> <dd></dd> <dt><a href="config.html#set-color-cycle-all!">set-color-cycle-all!</a></dt> <dd></dd> @@ -502,10 +432,6 @@ <dd></dd> <dt><a href="config.html#set-saturation!">set-saturation!</a></dt> <dd></dd> -<dt><a href="ui.html#set-selected-unit-changed-hook">set-selected-unit-changed-hook</a></dt> -<dd></dd> -<dt><a href="ui.html#set-selection-changed-hook">set-selection-changed-hook</a></dt> -<dd></dd> <dt><a href="config.html#set-selection-style!">set-selection-style!</a></dt> <dd></dd> <dt><a href="game.html#set-shared-vision!">set-shared-vision!</a></dt> diff --git a/doc/scripts/ui.html b/doc/scripts/ui.html index c7d311fcd..b7fd478f2 100644 --- a/doc/scripts/ui.html +++ b/doc/scripts/ui.html @@ -47,50 +47,7 @@ <a href="unittype.html">NEXT</a> <a href="ccl-index.html">Index</a> <hr> -<a href="#add-button">add-button</a> -<a href="#set-selection-changed-hook">set-selection-changed-hook</a> -<a href="#set-selected-unit-changed-hook">set-selected-unit-changed-hook</a> -<a href="#set-choose-target-begin-hook">set-choose-target-begin-hook</a> -<a href="#set-choose-target-finish-hook">set-choose-target-finish-hook</a> -<a href="#add-button">add-button</a> -<a href="#remove-button">remove-button</a> -<a href="#remove-all-buttons">remove-all-buttons</a> - -<a href="#command-patrol">command-patrol</a> -<a href="#command-harvest">command-harvest</a> -<a href="#command-attack">command-attack</a> -<a href="#command-cancel-upgrade">command-cancel-upgrade</a> -<a href="#command-build">command-build</a> -<a href="#command-train-unit">command-train-unit</a> -<a href="#command-cast-spell">command-cast-spell</a> -<a href="#command-move">command-move</a> -<a href="#command-stop">command-stop</a> -<a href="#command-research">command-research</a> -<a href="#command-unload">command-unload</a> -<a href="#command-upgrade-to">command-upgrade-to</a> -<a href="#command-attack-ground">command-attack-ground</a> -<a href="#command-return-goods">command-return-goods</a> -<a href="#command-cancel">command-cancel</a> -<a href="#command-cancel-building">command-cancel-building</a> -<a href="#command-cancel-train-unit">command-cancel-train-unit</a> -<a href="#command-repair">command-repair</a> -<a href="#command-stand-ground">command-stand-ground</a> -<a href="#command-demolish">command-demolish</a> - -<a href="#check-allowed">check-allowed</a> -<a href="#get-cost-string">get-cost-string</a> - -<a href="#selected-is-building">selected-is-building</a> -<a href="#selected-is-training">selected-is-training</a> -<a href="#selected-is-upgrading">selected-is-upgrading</a> -<a href="#selected-get-race">selected-get-race</a> -<a href="#selected-get-speed">selected-get-speed</a> -<a href="#selected-owned-by-player">selected-owned-by-player</a> -<a href="#selected-mixed-units">selected-mixed-units</a> -<a href="#selected-get-action">selected-get-action</a> -<a href="#selected-resource-loaded">selected-resource-loaded</a> -<a href="#selected-draw-buttons">selected-draw-buttons</a> - +<a href="#define-button">define-button</a> <a href="#define-cursor">define-cursor</a> <a href="#define-font">define-font</a> <a href="#define-font-colors">define-font-colors</a> @@ -107,30 +64,46 @@ Everything around the user interface. <h2>Functions</h2> -<a name="add-button"></a> -<h3>(add-button 'tag1 value1 'tag2 value2 ...)</h3> +<a name="define-button"></a> +<h3>(define-button 'tag1 value1 'tag2 value2 ...)</h3> -Add a button to the button panel during the game. This is usually -called from the 'button-hook of the unittypes (FIXME link), or from -the selection-changed-hook (FIXME link) directly. -See also (remove-all-buttons) (FIXME link)<br> -Possible tags: +Define a button in the button panel show during the game. Possible tags: <dl> +<dt>forunit</dt> +<dd>List of units the button applies to, or '(*) for all units. +</dd> <dt>pos</dt> -<dd>Position number. Currently buttons can be added only to the button -panel. +<dd>Position number. <pre> 0 1 2 3 4 5 6 7 8 </pre> </dd> +<dt>level</dt> +<dd>Visible when in this button level (0 default, 9 cancel-only) +</dd> <dt>icon</dt> <dd>Name of the icon to display. </dd> <dt>action</dt> -<dd>Script to eval when the button is pressed. +<dd>Action to perform when the button is clicked. Can be any of the following: +move, stop, attack, repair, harvest, button, build, train-unit, patrol, +stand-ground, attack-ground, return-goods, demolish, cast-spell, research, +upgrade-to, unload, cancel, cancel-upgrade, cancel-train-unit, cancel-build. +</dd> +<dt>value</dt> +<dd>Optional value associated with the action. +</dd> +<dt>allowed</dt> +<dd>Optional check to see if a button is allowed. Can be any of the following: +check-true, check-false, check-upgrade, check-units-or, check-units-and, +check-network, check-no-work, check-no-research, check-attack, +check-upgrade-to, check-research, check-single-research. +</dd> +<dt>allowarg</dt> +<dd>Optional argument used by the allowed function. </dd> <dt>key</dt> <dd>Shortcut key for the button. @@ -138,394 +111,17 @@ panel. <dt>hint</dt> <dd>Hint to be displayed for the button. </dd> -<dt>highlight</dt> -<dd>If given and true, highlight the button by drawing an extra border -(used for showing actions). -</dd> </dl> <h4>Example</h4> <pre> - ;; add a patrol button - (add-button 'pos 4 - 'icon (string-append "icon-" (selected-get-race) "-patrol-land") - 'key "p" 'hint "~!PATROL" - 'action (lambda () (command-patrol))) + (define-button 'pos 9 'level 0 'icon 'icon-exorcism + 'action 'cast-spell 'value 'spell-exorcism + 'allowed 'check-upgrade 'allow-arg '(upgrade-exorcism) + 'key "e" 'hint "~!EXORCISM" + 'for-unit '(unit-paladin unit-knight-rider unit-man-of-light)) </pre> -<a name="remove-button"></a> -<h3>(remove-button id)</h3> -Remove button number id. -<h4>Example</h4> - (remove-button 4) -<pre> -</pre> - -<a name="remove-all-buttons"></a> -<h3>(remove-all-buttons)</h3> -Removes all buttons from the button panel. - -<a name="set-selection-changed-hook"></a> -<h3>(set-selection-changed-hook '(begin ...))</h3> -Set the script that will be evaluated whenever the player selects an other set of units. -You will probably want call things like <a href="#remove-all-buttons">remove-all-buttons</a> -and <a href="#add-button">add-button</a> here, after examining the selection with other helper functions. -<p> -I suggest you define a helper function that rebuilds the buttons, and -call it from both selection-changed-hook and -<a href="#set-selected-unit-changed-hook">selected-unit-changed-hook</a>. - -<h4>Example</h4> -<pre> - ; (Those are extracts from the demogame ccls) - - ; FIXME: this is most likely a very ugly hack to scheme - (define (set-global symbol value) - (set-symbol-value! symbol value nil)) - (define (get-global symbol) - (symbol-value symbol nil)) - - (set-selection-changed-hook '(begin - (set-global 'button-level 0) - (rebuild-buttons))) - - (set-selected-unit-changed-hook '(begin - (rebuild-buttons))) - - ; Build all the command buttons from scratch. - (define (rebuild-buttons) - (remove-all-buttons) - (if (selected-owned-by-player) (begin - ; draw some generic buttons - (if (= (get-global 'button-level) 0) (begin - (if (> (selected-get-speed) 0) (begin - (generic-movement-buttons) - (if (selected-mixed-units) (begin - (generic-combat-buttons)) - ; Uniform selection: draw the unit's own buttons - (selected-draw-buttons)))) - (if (selected-is-building) (begin - ; there can be only one building selected - ; no common buttons should be here for now, - ; "destroy building" or something could be added. - (add-button 'pos 7 - 'icon 'icon-move-peasant - 'key "m" 'hint "SET ~!MOVE" - 'action (lambda () (command-move))) - ; - ; Call the building's own button-draw hook - ; - (selected-draw-buttons) - ; FIXME: maybe non-buildings could be upgrading too - ; note: upgrade is both researching and changing unit type - (if (selected-is-upgrading) (begin - ; could be optimized by not calling (selected-draw-buttons) - (remove-all-buttons) - (add-button 'pos 9 'icon 'icon-cancel - 'key "\033" 'hint "~<ESC~> CANCEL UPGRADE" - 'action (lambda() (command-cancel-upgrade)))))))) - (begin ; else: button level is not zero - ; - ; Generic cancel button to go back to button level 0 - ; - (add-button 'pos 9 'icon 'icon-cancel - 'key "\033" 'hint "~<ESC~> CANCEL" - 'action (lambda() - (set-global 'button-level 0) - (rebuild-buttons))) - ; - ; Call the unit's own button-draw hook - ; - (selected-draw-buttons)))))) - ; no command buttons for enemy units. -</pre> - -<a name="set-selected-unit-changed-hook"></a> -<h3>(set-selected-unit-changed-hook)</h3> - -Set the script that will be evaluated when one of the selected units -experiences some kind of upgrade, or when a global research is -completed (this is when you might want new buttons to appear, or old -ones to remove, or button images to be changed). This is seperated -from <a href="#set-selection-changed-hook">set-selection-changed-hook</a> -because you probably don't want to break out of a subbutton (eg selecting -the building to build) here. - -<h4>Example</h4> -<pre> - (set-selected-unit-changed-hook '(begin - (writes nil "[debug] selected-unit-changed-hook called") - (rebuild-buttons))) -</pre> - -<a name="set-choose-target-begin-hook"></a> -<h3>(set-choose-target-begin-hook)</h3> - -Set the script that will be evaluated when the user is asked to select -some target. You will want to change the buttons. FIXME: other hooks -can interrupt the select-target process, so a global flag must be set - -<h4>Example</h4> -<pre> - ; When doing a target selection, only draw a cancel button. - ; If you leave them both empty, you can choose another building while - ; setting the destination and similar things. - (set-choose-target-begin-hook '(begin - (set-global 'button-level 9) - (rebuild-buttons))) - (set-choose-target-finish-hook '(begin - (set-global 'button-level 0) - (rebuild-buttons))) -</pre> - -<a name="set-choose-target-finish-hook"></a> -<h3>(set-choose-target-finish-hook)</h3> -Set the script that will be evaluated when the user has finished to -select a target. See <a href="#set-choose-target-begin-hook">set-choose-target-begin-hook</a> -for details. - -<a name="command-patrol"></a> -<h3>(command-patrol)</h3> -(While game is running) Let the player select a destination where the -currently selected units will patrol to. - -<a name="command-harvest"></a> -<h3>(command-harvest)</h3> -(While game is running) Let the player select a destination where the -currently selected units will harvest. - -<a name="command-attack"></a> -<h3>(command-attack)</h3> -(While game is running) Let the player select a destination where the -currently selected units will attack. - -<a name="command-cancel-upgrade"></a> -<h3>(command-cancel-upgrade)</h3> -(While game is running) Cancel the upgrade the currently selected unit -is doing. - -<a name="command-build"></a> -<h3>(command-build unittype)</h3> -(While game is running) Let the player select a destination where a -building will be placed. Costs are checked. -<h4>Example</h4> -<pre> - (command-build 'unit-farm) -</pre> - -<a name="command-train-unit"></a> -<h3>(command-train-unit unittype)</h3> -(While game is running) Let the current unit train another unit (I -wonder whether this works with non-buildings, too?) -<h4>Example</h4> -<pre> - ; define a helper function to add training buttons - (define (train-button type pos key hint) - (if (check-allowed (string-append 'unit- type)) - (add-button - 'icon (string-append 'icon- type) - 'hint (string-append hint " " (get-cost-string (string-append 'unit- type))) - 'pos pos - 'key key - 'action (lambda () - (writes nil "Train-command\n") - (command-train-unit (string-append 'unit- type)))))) -</pre> - -<a name="command-cast-spell"></a> -<h3>(command-cast-spell spellid)</h3> -(While game is running) Let the current unit(selection) cast a spell. -<br>FIXME: untested. - -<h4>Example</h4> -<pre> - FIXME -</pre> - -<a name="command-move"></a> -<h3>(command-move)</h3> -(While game is running) Let the player select a destination where the -currently selected units will move to. - -<a name="command-stop"></a> -<h3>(command-stop)</h3> -(While game is running) stop the selected units. - -<a name="command-research"></a> -<h3>(command-research upgrade)</h3> -(While game is running) Command the selected unit to research the -given upgrade. - -<a name="command-unload"></a> -<h3>(command-unload)</h3> -(While game is running) Let the player select a destination where the -currently selected unit(s) will unload to. - -<a name="command-upgrade-to"></a> -<h3>(command-upgrade-to unittype)</h3> -(While game is running) Command the selected unit to upgrade to -another unittype. - -<a name="command-attack-ground"></a> -<h3>(command-attack-ground)</h3> -(While game is running) Let the player select a destination where the -currently selected unit(s) will attack a ground area. - -<a name="command-return-goods"></a> -<h3>(command-return-goods)</h3> -(While game is running) Let the currently selected units return their -goods. - -<a name="command-cancel"></a> -<h3>(command-cancel)</h3> -(While game is running) This cancels selecting a -destination. (FIXME: or is it used elsewhere too?) - -<a name="command-cancel-building"></a> -<h3>(command-cancel-building)</h3> -(While game is running) This cancels building. -(FIXME: does it work?) - -<a name="command-cancel-train-unit"></a> -<h3>(command-cancel-train-unit)</h3> -(While game is running) Let the first selected unit remove one item -from the training queue. -(FIXME: or does it rather empty the training queue completely?) - -<a name="command-repair"></a> -<h3>(command-repair)</h3> -(While game is running) Let the player select a destination that the -currently selected units will repair. - -<a name="command-stand-ground"></a> -<h3>(command-stand-ground)</h3> -Command the selected units not to move. (FIXME: correct?) - -<a name="command-demolish"></a> -<h3>(command-demolish)</h3> -(While game is running) Let the player select a destination where the -currently selected units go demolishing (explode there). - -<a name="check-allowed"></a> -<h3>(check-allowed thing)</h3> -Check whether thing is allowed. Thing can be an upgrade or an unit. -<h4>Example</h4> -<pre> - (if (check-allowed 'unit-keep) - (add-button 'pos 2 - 'icon 'icon-keep - 'key "k" - 'hint (string-append "UPGRADE TO ~!KEEP " (get-cost-string 'unit-keep)) - 'action (lambda () (command-upgrade-to 'unit-keep)))) -</pre> - -<a name="get-cost-string"></a> -<h3>(get-cost-string thing)</h3> -Returns a string with the costs of thing (unit or upgrade), useful to -give as button hint. -<br> -The string contains the special characters like -"$1" that will let a resource icon appear instead of the -text. - -<h4>Example</h4> -<pre> - 'hint (string-append "UPGRADE TO ~!KEEP " (get-cost-string 'unit-keep)) -</pre> - -<a name="selected-is-building"></a> -<h3>(selected-is-building)</h3> -Returns true if the selected unit is a building. FIXME: bad name - -<a name="selected-is-training"></a> -<h3>(selected-is-training)</h3> -Returns true if the selected unit is training. - -<a name="selected-is-upgrading"></a> -<h3>(selected-is-upgrading)</h3> -Returns true if the selected unit is upgrading. - -<a name="selected-get-race"></a> -<h3>(selected-get-race)</h3> -Returns the race of the selected unit. -<h4>Example</h4> -<pre> - ; not yet used, could be useful for something like - 'icon (string-append "icon-" (selected-get-race) "shield1") - ; if the icons are named properly -</pre> - -<a name="selected-get-speed"></a> -<h3>(selected-get-speed)</h3> - -Gets the speed of the selected unit, as defined in the -unittype. Useful to decide whether to draw a movement button. -<br> -Note that the speed declared in the unittype is just to display something, -the real unit speed is hidden in the animation script. - -<a name="selected-owned-by-player"></a> -<h3>(selected-owned-by-player)</h3> - -Returns true if the selected unit(s) is owned by the current -player. -<br> -Note that the player cannot select more than one enemy unit a -a time. - -<a name="selected-mixed-units"></a> -<h3>(selected-mixed-units)</h3> -Returns true if the selection contains more than one unittype. -<h4>Example</h4> -<pre> - (if (selected-mixed-units) (begin - ; attack/stand/patrol buttons for mixed selections - (generic-combat-buttons)) - ; Uniform selection: draw the unit's own buttons - (selected-draw-buttons)) -</pre> - -<a name="selected-get-action"></a> -<h3>(selected-get-action)</h3> -Returns the name of the current action as a string. Possible values are: -<p> -Invalid (No unit selected), Mixed (multiple units selected, and they -are doing different things), None, Still, StandGround, Follow, Move, -Attack, AttackGround, Die, SpellCast, Train, Train, UpgradeTo, -Research, Builded, Board, Unload, Patrol, Build, Repair, Resource, -ReturnGoods, Demolish. -<p> -Note that those are case-sensitive. - -<h4>Example</h4> -<pre> - (add-button 'pos 3 - 'icon (string-append "icon-sword1") - 'key "a" 'hint "~!ATTACK" - 'highlight (= (strcmp (selected-get-action) 'Attack) 0) - 'action (lambda () (command-attack)))) -</pre> - -<a name="selected-resource-loaded"></a> -<h3>(selected-resource-loaded)</h3> -Returns the name of the resource the selected units have loaded, -'mixed if there are different resources loaded, or nil (false) if -there are no resources loaded. -<h4>Example</h4> -<pre> - (if (selected-resource-loaded) (begin - (writes nil (string-append "[debug] Selected unit has loaded " (selected-resource-loaded) " resources.\n")) - (add-button 'pos 6 - ; could build icon string from the resource name :) - 'icon 'icon-return-goods-peasant - 'key "g" 'hint "RETURN WITH ~!GOODS" - 'action (lambda () (command-return-goods))))) -</pre> - -<a name="selected-draw-buttons"></a> -<h3>(selected-draw-buttons)</h3> -Run the 'add-buttons hook from the first selected unittype. - <a name="define-cursor"></a> <h3>(define-cursor 'ident 'race 'tag1 value1 'tag2 value2 ...)</h3> @@ -1069,21 +665,20 @@ All of those tags should be given: minimapx (+ minimapy 148)) </pre> </dd> -<dt>minimap</dt> +<dt>minimap-panel</dt> <dd> <pre> - 'minimap (list - 'file (string-append "graphics/ui/" race "/minimap.png") - 'panel-pos (list minimapx minimapy) - 'pos (list (+ minimapx 27) (+ minimapy 13)) - 'size '(128 128) - 'transparent) + 'minimap-panel (list + (string-append "graphics/ui/" race "/minimap.png") + minimapx minimapy) +</pre> +</dd> +<dt>minimap-pos</dt> +<dd> +<pre> + 'minimap-pos (list + (+ minimapx 27) (+ minimapy 13)) </pre> -There is a minimap panel an the minimap on it. The panel graphic has -certain palette restrictions (FIXME: exactly? probably the same as the -tileset?). Pos is the absoloute position of the minimap on the screen -(the upper left corner of it). If you give 'transparent, the panel -graphic will be displayed on unexplored terrain, black otherwise. </dd> <dt>status-line</dt> <dd> diff --git a/src/action/action_attack.cpp b/src/action/action_attack.cpp index 49d5de8be..1e932d87b 100644 --- a/src/action/action_attack.cpp +++ b/src/action/action_attack.cpp @@ -52,9 +52,6 @@ #include "map.h" #include "pathfinder.h" #include <string.h> -#ifdef NEW_UI -#include "interface.h" -#endif /*---------------------------------------------------------------------------- -- Defines @@ -165,13 +162,7 @@ local Unit* CheckForDeadGoal(Unit* unit) unit->SavedOrder.Goal = NoUnitP; if (unit->Selected && unit->Player == ThisPlayer) { -#ifndef NEW_UI MustRedraw |= RedrawButtonPanel; -#else - // FIXME: not really used because actions - // cannot yet be shown with NEW_UI - SelectedUnitChanged(); -#endif } goal = unit->Orders[0].Goal; } @@ -377,11 +368,7 @@ local void MoveToTarget(Unit* unit) unit->SavedOrder.Goal = NoUnitP; if (unit->Selected && unit->Player == ThisPlayer) { -#ifndef NEW_UI MustRedraw |= RedrawButtonPanel; -#else - SelectedUnitChanged(); -#endif } return; } @@ -454,11 +441,7 @@ local void AttackTarget(Unit* unit) DebugCheck(unit->SavedOrder.Goal != NoUnitP); if (unit->Selected && unit->Player == ThisPlayer) { -#ifndef NEW_UI MustRedraw |= RedrawButtonPanel; -#else - SelectedUnitChanged(); -#endif } } return; diff --git a/src/action/action_move.cpp b/src/action/action_move.cpp index 1a1ffe7fb..54e065dd9 100644 --- a/src/action/action_move.cpp +++ b/src/action/action_move.cpp @@ -154,11 +154,9 @@ local int ActionMoveGeneric(Unit* unit, const Animation* anim) MapMarkUnitSight(unit); // Remove unit from the current selection if (unit->Selected && !IsMapFieldVisible(ThisPlayer, unit->X, unit->Y)) { -#ifndef NEW_UI if (NumSelected == 1) { // Remove building cursor CancelBuildingMode(); } -#endif UnSelectUnit(unit); SelectionChanged(); } diff --git a/src/action/action_train.cpp b/src/action/action_train.cpp index 83768ebc8..1cf36e667 100644 --- a/src/action/action_train.cpp +++ b/src/action/action_train.cpp @@ -194,13 +194,8 @@ global void HandleActionTrain(Unit* unit) } if (IsOnlySelected(unit)) { -#ifndef NEW_UI UpdateButtonPanel(); MustRedraw |= RedrawPanels; -#else - SelectedUnitChanged(); - MustRedraw |= RedrawInfoPanel; -#endif } return; diff --git a/src/include/cursor.h b/src/include/cursor.h index 7eb8a3b6c..dddf40032 100644 --- a/src/include/cursor.h +++ b/src/include/cursor.h @@ -179,11 +179,7 @@ extern CursorType* Cursors; /// cursor-types description extern CursorStates CursorState; /// current cursor state (point,...) extern int CursorAction; /// action for selection -#ifndef NEW_UI extern int CursorValue; /// value for action (spell type f.e.) -#else -extern int CursorSpell; /// spell type for target selection -#endif extern UnitType* CursorBuilding; /// building cursor extern CursorType* GameCursor; /// cursor-type diff --git a/src/include/interface.h b/src/include/interface.h index 5fddd5ed1..cb9309726 100644 --- a/src/include/interface.h +++ b/src/include/interface.h @@ -40,9 +40,6 @@ #include "player.h" #include "unit.h" #include "icons.h" -#ifdef NEW_UI -#include "ccl.h" -#endif /*---------------------------------------------------------------------------- -- Definitons @@ -60,7 +57,6 @@ enum _button_cmd_ { ButtonSpellCast, /// order cast spell ButtonUnload, /// order unload unit ButtonDemolish, /// order demolish/explode -#ifndef NEW_UI ButtonStop, /// order stop ButtonButton, /// choose other button set ButtonTrain, /// order train @@ -72,18 +68,14 @@ enum _button_cmd_ { ButtonCancelUpgrade, /// cancel upgrade ButtonCancelTrain, /// cancel training ButtonCancelBuild, /// cancel building -#endif }; /// typedef for action of button typedef struct _button_action_ ButtonAction; -#ifndef NEW_UI typedef int (*ButtonCheckFunc)(const Unit*,const ButtonAction*); -#endif /// Action of button struct _button_action_ { -#ifndef NEW_UI int Pos; /// button position in the grid int Level; /// requires button level enum _button_cmd_ Action; /// command on button press @@ -93,10 +85,6 @@ struct _button_action_ { ButtonCheckFunc Allowed; char* AllowStr; /// argument for allowed char* UnitMask; /// for which units is it available -#else - SCM Action; /// script on button press - int Highlight; /// whether to draw a border -#endif IconConfig Icon; /// icon to display int Key; /// alternative on keyboard char* Hint; /// tip text @@ -309,18 +297,11 @@ extern void DrawConsole(void); extern void InitButtons(void); /// Free memory for buttons extern void CleanButtons(void); -#ifndef NEW_UI /// Make a new button extern int AddButton(int pos,int level,const char* IconIdent, enum _button_cmd_ action,const char* value, const ButtonCheckFunc func,const void* arg, int key,const char* hint,const char* umask); -#else - /// Add a new button to the command panel -extern void AddButton(int pos, char *icon_ident, SCM action, int key, char *hint, int highlight); - /// Remove a single button from the panel -global void RemoveButton(int pos); -#endif /// Save all buttons extern void SaveButtons(CLFile* file); @@ -407,13 +388,11 @@ extern void ClearStatusLine(void); /// Draw status line extern void DrawStatusLine(void); /// Draw costs in status line -#ifndef NEW_UI extern void DrawCosts(void); /// Set costs to be displayed in status line extern void SetCosts(int,int,const int* costs); /// Clear the costs displayed in status line (undisplay!) extern void ClearCosts(void); -#endif /// Draw the unit info panel extern void DrawInfoPanel(void); @@ -426,18 +405,13 @@ extern void DrawButtonPanel(void); /// Update the content of the unit button panel extern void UpdateButtonPanel(void); /// Handle button click in button panel area -#ifndef NEW_UI extern void DoButtonButtonClicked(int button); -#else -extern void DoButtonButtonClicked(int pos); -#endif /// Lookup key for bottom panel buttons extern int DoButtonPanelKey(int key); /// Handle the mouse in scroll area extern int HandleMouseScrollArea(int,int); -#ifndef NEW_UI // // in button_checks.c // @@ -467,7 +441,6 @@ extern int ButtonCheckUpgradeTo(const Unit*,const ButtonAction*); extern int ButtonCheckResearch(const Unit*,const ButtonAction*); /// Check if all requirements for a single research are meet extern int ButtonCheckSingleResearch(const Unit*,const ButtonAction*); -#endif // // in ccl_ui.c @@ -476,12 +449,6 @@ extern int ButtonCheckSingleResearch(const Unit*,const ButtonAction*); extern void SelectionChanged(void); /// Called whenever the selected unit was updated extern void SelectedUnitChanged(void); -#ifdef NEW_UI - /// Enter target selection mode -extern void ChooseTargetBegin(int action); - /// Clean up when leaving target selection mode -extern void ChooseTargetFinish(void); -#endif //@} diff --git a/src/include/stratagus.h b/src/include/stratagus.h index a5d449b72..d2f38bd9e 100644 --- a/src/include/stratagus.h +++ b/src/include/stratagus.h @@ -401,9 +401,7 @@ enum _must_redraw_flags_ { RedrawFillers = 1<<17, /// Fillers RedrawMinimapBorder = 1<<18, /// Area around minimap -#ifndef NEW_UI RedrawCosts = 1<<19, /// Costs in status line -#endif RedrawMenuButton = 1<<20, /// Area above minimap RedrawMinimapCursor = 1<<21, /// Minimap cursor changed RedrawMenu = 1<<22, /// Menu diff --git a/src/include/ui.h b/src/include/ui.h index d5b3f3196..18f1902f9 100644 --- a/src/include/ui.h +++ b/src/include/ui.h @@ -333,12 +333,6 @@ extern int SpeedKeyScroll; /// Keyboard Scrolling Speed, in Frames extern int SpeedMouseScroll; /// Mouse Scrolling Speed, in Frames // only exported to save them -#ifdef NEW_UI -extern SCM SelectionChangedHook; /// Script to add/remove buttons -extern SCM SelectedUnitChangedHook; /// Script to refresh buttons -extern SCM ChooseTargetBeginHook; /// Script to draw target selection buttons -extern SCM ChooseTargetFinishHook; /// Script to draw target selection buttons -#endif /*---------------------------------------------------------------------------- -- Functions diff --git a/src/include/unittype.h b/src/include/unittype.h index 8c757debd..d6b888272 100644 --- a/src/include/unittype.h +++ b/src/include/unittype.h @@ -598,9 +598,6 @@ #include "upgrade_structs.h" #include "construct.h" #include "etlib/hash.h" -#ifdef NEW_UI -#include "ccl.h" -#endif /*---------------------------------------------------------------------------- -- Declarations @@ -820,10 +817,6 @@ struct _unit_type_ { #ifdef USE_OPENGL Graphic* PlayerColorSprite[PlayerMax]; /// Sprites with player colors #endif -#ifdef NEW_UI - - SCM AddButtonsHook; /// Script called to add UI buttons -#endif }; // FIXME: ARI: should be dynamic (ccl..), JOHNS: Pud only supports 255. diff --git a/src/stratagus/mainloop.cpp b/src/stratagus/mainloop.cpp index 5d35373d8..16e2d9954 100644 --- a/src/stratagus/mainloop.cpp +++ b/src/stratagus/mainloop.cpp @@ -610,15 +610,11 @@ global void UpdateDisplay(void) } if( MustRedraw&RedrawStatusLine ) { DrawStatusLine(); -#ifndef NEW_UI MustRedraw|=RedrawCosts; -#endif } -#ifndef NEW_UI if( MustRedraw&RedrawCosts ) { DrawCosts(); } -#endif if( MustRedraw&RedrawTimer ) { DrawTimer(); } @@ -708,11 +704,7 @@ global void UpdateDisplay(void) ,TheUI.Resource.Graphic->Width ,TheUI.Resource.Graphic->Height); } -#ifndef NEW_UI if( (MustRedraw&RedrawStatusLine || MustRedraw&RedrawCosts) && TheUI.StatusLine.Graphic ) { -#else - if( MustRedraw&RedrawStatusLine && TheUI.StatusLine.Graphic ) { -#endif InvalidateAreaAndCheckCursor( TheUI.StatusLineX,TheUI.StatusLineY ,TheUI.StatusLine.Graphic->Width diff --git a/src/stratagus/player.cpp b/src/stratagus/player.cpp index 7958629a2..710a67b09 100644 --- a/src/stratagus/player.cpp +++ b/src/stratagus/player.cpp @@ -192,7 +192,6 @@ global void SavePlayers(CLFile* file) CLprintf(file,"\n;;; -----------------------------------------\n"); CLprintf(file,";;; MODULE: players $Id$\n\n"); -#ifndef NEW_UI // // Dump table wc2 race numbers -> internal symbol. // @@ -210,7 +209,6 @@ global void SavePlayers(CLFile* file) } CLprintf(file,")\n\n"); } -#endif // // Dump table wc2 race numbers -> internal symbol. diff --git a/src/ui/botpanel.cpp b/src/ui/botpanel.cpp index 98184624b..372548292 100644 --- a/src/ui/botpanel.cpp +++ b/src/ui/botpanel.cpp @@ -56,10 +56,8 @@ -- Defines ----------------------------------------------------------------------------*/ -#ifndef NEW_UI /// How many different buttons are allowed #define MAX_BUTTONS 2048 -#endif /*---------------------------------------------------------------------------- -- Variables @@ -68,14 +66,12 @@ /// Display the command key in the buttons. global char ShowCommandKey; -#ifndef NEW_UI /// for unit buttons sub-menus etc. global int CurrentButtonLevel; /// All buttons for units local ButtonAction* UnitButtonTable[MAX_BUTTONS]; /// buttons in UnitButtonTable local int NumUnitButtons; -#endif /*---------------------------------------------------------------------------- -- Functions @@ -86,7 +82,6 @@ local int NumUnitButtons; */ global void InitButtons(void) { -#ifndef NEW_UI int z; // @@ -96,10 +91,6 @@ global void InitButtons(void) UnitButtonTable[z]->Icon.Icon = IconByIdent(UnitButtonTable[z]->Icon.Name); } -#else - // FIXME: proabably not necessary - //CleanButtons(); -#endif } /** @@ -107,16 +98,13 @@ global void InitButtons(void) */ global void SaveButtons(CLFile* file) { -#ifndef NEW_UI int i; int n; char* cp; -#endif CLprintf(file, "\n;;; -----------------------------------------\n"); CLprintf(file, ";;; MODULE: buttons $Id$\n\n"); -#ifndef NEW_UI for (i = 0; i < NumUnitButtons; ++i) { CLprintf(file, "(define-button 'pos %d 'level %d 'icon '%s\n", UnitButtonTable[i]->Pos, UnitButtonTable[i]->Level, @@ -250,25 +238,6 @@ global void SaveButtons(CLFile* file) } CLprintf(file, "))\n\n"); } -#else - - CLprintf(file, "(set-selection-changed-hook '"); - lprin1CL(SelectionChangedHook, file); - CLprintf(file, ")\n"); - - CLprintf(file, "(set-selected-unit-changed-hook '"); - lprin1CL(SelectedUnitChangedHook, file); - CLprintf(file, ")\n"); - - CLprintf(file, "(set-choose-target-begin-hook '"); - lprin1CL(ChooseTargetBeginHook, file); - CLprintf(file, ")\n"); - - CLprintf(file, "(set-choose-target-finish-hook '"); - lprin1CL(ChooseTargetFinishHook, file); - CLprintf(file, ")\n"); - -#endif CLprintf(file, "(set-show-command-key! %s)\n\n", ShowCommandKey ? "#t" : "#f"); @@ -291,42 +260,18 @@ global void SaveButtons(CLFile* file) -- Buttons structures ----------------------------------------------------------------------------*/ -#ifndef NEW_UI global ButtonAction* CurrentButtons; /// Pointer to current buttons local ButtonAction _current_buttons[9]; /// FIXME: this is just for test -#else -global ButtonAction CurrentButtons[9]; /// Pointer to current buttons -#endif -#ifdef NEW_UI -local void CleanButton(ButtonAction* ba) -{ - if (!ba->Icon.Name) { - return; - } - free(ba->Icon.Name); - CclGcUnprotect(ba->Action); - memset(ba, 0, sizeof(*ba)); - MustRedraw |= RedrawButtonPanel; -} -#endif /// FIXME: docu -#ifndef NEW_UI int AddButton(int pos, int level, const char* icon_ident, enum _button_cmd_ action, const char* value, const ButtonCheckFunc func, const void* allow, int key, const char* hint, const char* umask) -#else -global void AddButton(int pos, char *icon_ident, SCM action, int key, - char* hint, int highlight) -#endif { -#ifndef NEW_UI char buf[2048]; -#endif ButtonAction* ba; -#ifndef NEW_UI ba = (ButtonAction*)malloc(sizeof(ButtonAction)); DebugCheck(!ba); //FIXME: perhaps should return error? @@ -383,56 +328,14 @@ global void AddButton(int pos, char *icon_ident, SCM action, int key, // FIXME: check if already initited //DebugCheck(ba->Icon.Icon == NoIcon);// just checks, that's why at the end return 1; -#else - if (pos < 1 || pos > 9) { - DebugLevel0Fn("Bad button positon %d (Icon.Name=%s)\n" _C_ - pos _C_ icon_ident); - // FIXME: better way to kill the program? - DebugCheck(1); - } - ba = CurrentButtons + (pos - 1); - CleanButton(ba); - - // maxy: the caller does not free this pointer - ba->Icon.Name = icon_ident; - ba->Icon.Icon = IconByIdent(ba->Icon. Name); - if (ba->Icon.Icon == NoIcon) { - ba->Icon.Icon = IconByIdent(ba->Icon. Name); - DebugLevel0Fn("Icon not found: Icon.Name = %s\n" _C_ ba->Icon.Name); - // FIXME: better way to kill the program? or draw a - // Unknown-Icon and add a hint so the user can test the rest of the ccl? - DebugCheck(1); - } - - // maxy: the caller protected this from the GC - ba->Action = action; - - // maxy: the caller does not free this pointer - ba->Hint = hint; - MustRedraw |= RedrawButtonPanel; - ba->Key = key; - ba->Highlight = highlight; -#endif } -#ifdef NEW_UI -global void RemoveButton(int pos) -{ - if (pos < 1 || pos > 9) { - DebugLevel0Fn("Bad button positon %d\n" _C_ pos); - // FIXME: better way to kill the program? - DebugCheck(1); - } - CleanButton(CurrentButtons + (pos - 1)); -} -#endif /** ** Cleanup buttons. */ global void CleanButtons(void) { -#ifndef NEW_UI int z; // @@ -461,14 +364,6 @@ global void CleanButtons(void) CurrentButtonLevel = 0; CurrentButtons = NULL; -#else - int i; - - DebugLevel0Fn("CleanButtons()\n"); - for (i = 0; i < 9; ++i) { - CleanButton(CurrentButtons + i); - } -#endif } /** @@ -478,13 +373,9 @@ global void DrawButtonPanel(void) { int i; int v; -#ifndef NEW_UI const UnitStats* stats; const ButtonAction* buttons; char buf[8]; -#else - const ButtonAction* ba; -#endif // // Draw background @@ -495,26 +386,17 @@ global void DrawButtonPanel(void) TheUI.ButtonPanelX, TheUI.ButtonPanelY); } -#ifndef NEW_UI if (!(buttons = CurrentButtons)) { // no buttons return; } -#endif // FIXME: this is unneeded DrawUnitIcon does it self PlayerPixels(ThisPlayer); // could only select own units. -#ifndef NEW_UI for (i = 0; i < TheUI.NumButtonButtons; ++i) { if (buttons[i].Pos != -1) { int j; int action; -#else - //for (i = 0; i < TheUI.NumButtonButtons; ++i) { - for (i = 0; i < 9; ++i) { - ba = CurrentButtons + i; - if (ba->Icon.Icon != NoIcon) { -#endif // cursor is on that button if (ButtonAreaUnderCursor == ButtonAreaButton && @@ -538,7 +420,6 @@ global void DrawButtonPanel(void) should be re-enabled from ccl as a boolean button option, together with something like (selected-action-is 'patrol) */ -#ifndef NEW_UI action = UnitActionNone; switch (buttons[i].Action) { case ButtonStop: @@ -617,26 +498,15 @@ global void DrawButtonPanel(void) break; } } -#else - if (ba->Highlight) { - v |= IconSelected; - } -#endif -#ifndef NEW_UI DrawUnitIcon(ThisPlayer,buttons[i].Icon.Icon, v, TheUI.ButtonButtons[i].X, TheUI.ButtonButtons[i].Y); -#else - DrawUnitIcon(ThisPlayer,ba->Icon.Icon, - v, TheUI.ButtonButtons[i].X, TheUI.ButtonButtons[i].Y); -#endif // // Update status line for this button // if (ButtonAreaUnderCursor == ButtonAreaButton && ButtonUnderCursor == i && KeyState != KeyStateInput) { -#ifndef NEW_UI SetStatusLine(buttons[i].Hint); // FIXME: Draw costs v = buttons[i].Value; @@ -668,9 +538,6 @@ global void DrawButtonPanel(void) ClearCosts(); break; } -#else - SetStatusLine(ba->Hint); -#endif } // @@ -678,26 +545,15 @@ global void DrawButtonPanel(void) // if (ShowCommandKey) { Button* b; -#ifdef NEW_UI - char buf[4]; -#endif b = &TheUI.ButtonButtons[i]; -#ifndef NEW_UI if (CurrentButtons[i].Key == 27) { -#else - if (ba->Key == 27) { -#endif strcpy(buf, "ESC"); VideoDrawText(b->X + 4 + b->Width - VideoTextLength(GameFont, buf), b->Y + 5 + b->Height - VideoTextHeight(GameFont), GameFont, buf); } else { // FIXME: real DrawChar would be useful -#ifndef NEW_UI buf[0] = toupper(CurrentButtons[i].Key); -#else - buf[0] = toupper(ba->Key); -#endif buf[1] = '\0'; VideoDrawText(b->X + 4 + b->Width - VideoTextLength(GameFont, buf), b->Y + 5 + b->Height - VideoTextHeight(GameFont), GameFont, buf); @@ -711,7 +567,6 @@ global void DrawButtonPanel(void) -- Functions ----------------------------------------------------------------------------*/ -#ifndef NEW_UI /** ** Update bottom panel for multiple units. */ @@ -1199,39 +1054,7 @@ global void DoButtonButtonClicked(int button) break; } } -#endif -#ifdef NEW_UI -global void DoButtonButtonClicked(int pos) -{ - ButtonAction* ba; - - ba = CurrentButtons + pos; - // - // Handle action on button. - // - //FIXME DebugLevel3Fn("Button clicked (button hint: %s).", ba->Hint); - - if (!gh_null_p(ba->Action)) { - PlayGameSound(GameSounds.Click.Sound, MaxSampleVolume); - - /* - if ([ccl debugging]) { // display executed command - gh_display(...); - gh_newline(); - } - */ - gh_apply(ba->Action, NIL); - } else { - if (ba->Hint) { - DebugLevel0Fn("Missing button action (button hint: %s)." _C_ ba->Hint); - } else { - // FIXME: remove this after testing - DebugLevel0Fn("You are clicking on empty space, aren't you ;)"); - } - } -} -#endif /** ** Lookup key for bottom panel buttons. @@ -1244,7 +1067,6 @@ global int DoButtonPanelKey(int key) { int i; -#ifndef NEW_UI if (CurrentButtons) { // buttons // cade: this is required for action queues SHIFT+M should be `m' @@ -1259,22 +1081,6 @@ global int DoButtonPanelKey(int key) } } } -#else - ButtonAction* ba; - - // cade: this is required for action queues SHIFT+M should be `m' - if (key >= 'A' && key <= 'Z') { - key = tolower(key); - } - - for (i = 0; i < 9; ++i) { - ba = CurrentButtons + i; - if (key == CurrentButtons[i].Key) { - DoButtonButtonClicked(i); - return 1; - } - } -#endif return 0; } diff --git a/src/ui/button_checks.cpp b/src/ui/button_checks.cpp index 7d7b698b3..a26025d5c 100644 --- a/src/ui/button_checks.cpp +++ b/src/ui/button_checks.cpp @@ -30,7 +30,6 @@ //@{ -#ifndef NEW_UI /*---------------------------------------------------------------------------- -- Includes ----------------------------------------------------------------------------*/ @@ -286,6 +285,3 @@ global int ButtonCheckSingleResearch(const Unit* unit, } //@} -#else -// FIXME: maxy: remove this file. -#endif diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index d0aec3e71..cf6e818af 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -119,9 +119,7 @@ local void UiBeginInput(void) KeyState = KeyStateInput; Input[0] = '\0'; InputIndex = 0; -#ifndef NEW_UI ClearCosts(); -#endif ShowInput(); } @@ -624,13 +622,8 @@ local void UiFindIdleWorker(void) LastIdleWorker = unit; SelectSingleUnit(unit); ClearStatusLine(); -#ifndef NEW_UI ClearCosts(); CurrentButtonLevel = 0; -#else - // stupid trick, just in case SelectionChanged() should be slow it - // will probably feel faster if you hear the sound at once :) -#endif PlayUnitSound(Selected[0], VoiceSelected); SelectionChanged(); ViewportCenterViewpoint(TheUI.SelectedViewport, unit->X, unit->Y); @@ -1260,11 +1253,9 @@ global int HandleKeyModifiersDown(unsigned key, unsigned keychar case KeyCodeAlt: KeyModifiers |= ModifierAlt; // maxy: disabled -#ifndef NEW_UI if (InterfaceState == IfaceStateNormal) { SelectedUnitChanged(); //VLADI: to allow alt-buttons } -#endif return 1; case KeyCodeSuper: KeyModifiers |= ModifierSuper; @@ -1303,11 +1294,9 @@ global int HandleKeyModifiersUp(unsigned key, case KeyCodeAlt: KeyModifiers &= ~ModifierAlt; // maxy: disabled -#ifndef NEW_UI if (InterfaceState == IfaceStateNormal) { SelectedUnitChanged(); //VLADI: to allow alt-buttons } -#endif return 1; case KeyCodeSuper: KeyModifiers &= ~ModifierSuper; diff --git a/src/ui/mainscr.cpp b/src/ui/mainscr.cpp index ac93cc70f..ee7fed4d1 100644 --- a/src/ui/mainscr.cpp +++ b/src/ui/mainscr.cpp @@ -919,67 +919,18 @@ local char StatusLine[STATUS_LINE_LEN]; /// status line/hints */ global void DrawStatusLine(void) { -#ifdef NEW_UI - int i; - int x; - char* startpos; - char* endpos; - char* endline; - char* s; -#endif if (TheUI.StatusLine.Graphic) { VideoDrawSubClip(TheUI.StatusLine.Graphic, 0, 0, TheUI.StatusLine.Graphic->Width, TheUI.StatusLine.Graphic->Height, TheUI.StatusLineX, TheUI.StatusLineY); } -#ifdef NEW_UI - // maxy: split "$1", "$2", ... from the string and draw resource icon instead - // beware: stringhandling in C :-/ -#endif if (StatusLine[0]) { PushClipping(); SetClipping(TheUI.StatusLineTextX, TheUI.StatusLineTextY, TheUI.StatusLineX + TheUI.StatusLine.Graphic->Width - 1, TheUI.StatusLineY + TheUI.StatusLine.Graphic->Height - 1); -#ifndef NEW_UI VideoDrawTextClip(TheUI.StatusLineTextX, TheUI.StatusLineTextY, TheUI.StatusLineFont, StatusLine); -#else - - // need one more to easily read one char too far - s = calloc(1, strlen(StatusLine) + 2); - strcpy(s, StatusLine); - startpos = s; - endline = s + strlen(s); - x = TheUI.StatusLineTextX; - do { - endpos = strchr(startpos, '$'); - if (!endpos) { - endpos = endline; - } else { - // replace the $ - *endpos = '\0'; - } - x += VideoDrawTextClip(x, TheUI.StatusLineTextY, - TheUI.StatusLineFont, startpos); - if (endpos[1] >= '0' && endpos[1] <= '9') { - i = endpos[1] - '0'; - if (TheUI.Resources[i].Icon.Graphic) { - VideoDrawSubClip(TheUI.Resources[i].Icon.Graphic, 0, - TheUI.Resources[i].IconRow * TheUI.Resources[i].IconH, - TheUI.Resources[i].IconW, TheUI.Resources[i].IconH, - x, TheUI.StatusLineY + 1); - // FIXME: hardcoded useable icon width - x += 15; - } - } else if (endpos[1] == '$') { - // escaped "$$" - endpos--; - } - // skip the "$1" characters - startpos = endpos + 2; - } while (startpos < endline); -#endif PopClipping(); } } @@ -1008,7 +959,6 @@ global void ClearStatusLine(void) } } -#ifndef NEW_UI /*---------------------------------------------------------------------------- -- COSTS ----------------------------------------------------------------------------*/ @@ -1114,7 +1064,6 @@ global void ClearCosts(void) memset(costs, 0, sizeof(costs)); SetCosts(0, 0, costs); } -#endif /*---------------------------------------------------------------------------- -- INFO PANEL diff --git a/src/ui/menu_proc.cpp b/src/ui/menu_proc.cpp index 9d6f0a050..79b96904f 100644 --- a/src/ui/menu_proc.cpp +++ b/src/ui/menu_proc.cpp @@ -2345,11 +2345,7 @@ global void ProcessMenu(const char* menu_id, int loop) MenuButtonUnderCursorSave = -1; MenuButtonCurSelSave = -1; -#ifndef NEW_UI CancelBuildingMode(); -#else - ChooseTargetFinish(); -#endif // Recursion protection: if (loop) { diff --git a/src/ui/mouse.cpp b/src/ui/mouse.cpp index ee103716e..39c11cb9a 100644 --- a/src/ui/mouse.cpp +++ b/src/ui/mouse.cpp @@ -78,7 +78,6 @@ global enum _cursor_on_ CursorOn=CursorOnUnknown; /// Cursor on field -- Functions ----------------------------------------------------------------------------*/ -#ifndef NEW_UI /** ** Cancel building cursor mode. */ @@ -91,7 +90,6 @@ global void CancelBuildingMode(void) CurrentButtonLevel = 0; // reset unit buttons to normal UpdateButtonPanel(); } -#endif /** ** Called when right button is pressed @@ -1024,15 +1022,9 @@ local void SendSpellCast(int sx, int sy) continue; // no unit can cast spell on himself // n0b0dy: why not? } -#ifndef NEW_UI // CursorValue here holds the spell type id SendCommandSpellCast(unit, x, y, dest, CursorValue, !(KeyModifiers & ModifierShift)); -#else - // CursorSpell here holds the spell type id - SendCommandSpellCast(unit, x, y, dest, CursorSpell, - !(KeyModifiers & ModifierShift)); -#endif } } @@ -1050,10 +1042,8 @@ local void SendCommand(int sx, int sy) x = sx / TileSizeX; y = sy / TileSizeY; -#ifndef NEW_UI CurrentButtonLevel = 0; // reset unit buttons to normal UpdateButtonPanel(); -#endif switch (CursorAction) { case ButtonMove: SendMove(sx, sy); @@ -1133,10 +1123,8 @@ local void DoSelectionButtons(int num,unsigned button __attribute__((unused))) } ClearStatusLine(); -#ifndef NEW_UI ClearCosts(); CurrentButtonLevel = 0; // reset unit buttons to normal -#endif SelectionChanged(); MustRedraw |= RedrawInfoPanel; } @@ -1158,57 +1146,11 @@ local void UISelectStateButtonDown(unsigned button __attribute__((unused))) vp = TheUI.MouseViewport; -#ifdef NEW_UI - // to redraw the cursor immediately (and avoid up to 1 sec delay - if (CursorBuilding) { - // Possible Selected[0] was removed from map - // need to make sure there is an unit to build - if (Selected[0] && (MouseButtons&LeftButton)) {// enter select mode - int x; - int y; - int i; - int j; - int explored; - - x = Viewport2MapX(TheUI.MouseViewport, CursorX); - y = Viewport2MapY(TheUI.MouseViewport, CursorY); - // FIXME: error messages - - explored = 1; - for (j = 0; explored && j < Selected[0]->Type->TileHeight; ++j) { - for (i = 0; i < Selected[0]->Type->TileWidth; ++i) { - if (!IsMapFieldExplored(ThisPlayer, x + i, y + j)) { - explored = 0; - break; - } - } - } - if (CanBuildUnitType(Selected[0], CursorBuilding, x, y) && - (explored || ReplayRevealMap)) { - PlayGameSound(GameSounds.PlacementSuccess.Sound, - MaxSampleVolume); - SendCommandBuildBuilding(Selected[0], x, y,CursorBuilding, - !(KeyModifiers & ModifierShift)); - if (KeyModifiers & ModifierAlt) { - return; - } - } else { - PlayGameSound(GameSounds.PlacementError.Sound, - MaxSampleVolume); - } - } - ChooseTargetFinish(); - // FIXME: maxy: this does not allow clicking on - // the minimap while choosing locations - return; - } -#endif // // Clicking on the map. // if (CursorOn == CursorOnMap) { -#ifndef NEW_UI ClearStatusLine(); ClearCosts(); CursorState = CursorStatePoint; @@ -1216,7 +1158,6 @@ local void UISelectStateButtonDown(unsigned button __attribute__((unused))) CurrentButtonLevel = 0; UpdateButtonPanel(); MustRedraw |= RedrawButtonPanel | RedrawCursor; -#endif sx = CursorX - vp->X + TileSizeX * vp->MapX; sy = CursorY - vp->Y + TileSizeY * vp->MapY; @@ -1230,9 +1171,6 @@ local void UISelectStateButtonDown(unsigned button __attribute__((unused))) } SendCommand(sx, sy); } -#ifdef NEW_UI - ChooseTargetFinish(); -#endif return; } @@ -1248,7 +1186,6 @@ local void UISelectStateButtonDown(unsigned button __attribute__((unused))) if (MouseButtons & LeftButton) { sx = mx * TileSizeX; sy = my * TileSizeY; -#ifndef NEW_UI ClearStatusLine(); ClearCosts(); CursorState = CursorStatePoint; @@ -1256,15 +1193,11 @@ local void UISelectStateButtonDown(unsigned button __attribute__((unused))) CurrentButtonLevel = 0; // reset unit buttons to normal UpdateButtonPanel(); MustRedraw |= RedrawButtonPanel | RedrawCursor; -#endif if (ClickMissile) { MakeLocalMissile(MissileTypeByIdent(ClickMissile), sx + TileSizeX / 2, sy + TileSizeY / 2, 0, 0); } SendCommand(sx, sy); -#ifdef NEW_UI - ChooseTargetFinish(); -#endif } else { ViewportCenterViewpoint(TheUI.SelectedViewport, mx, my); } @@ -1274,15 +1207,11 @@ local void UISelectStateButtonDown(unsigned button __attribute__((unused))) if (CursorOn==CursorOnButton) { // FIXME: other buttons? if (ButtonAreaUnderCursor == ButtonAreaButton) { -#ifdef NEW_UI - ChooseTargetFinish(); -#endif DoButtonButtonClicked(ButtonUnderCursor); return; } } -#ifndef NEW_UI ClearStatusLine(); ClearCosts(); CursorState = CursorStatePoint; @@ -1290,9 +1219,6 @@ local void UISelectStateButtonDown(unsigned button __attribute__((unused))) CurrentButtonLevel = 0; // reset unit buttons to normal UpdateButtonPanel(); MustRedraw |= RedrawButtonPanel | RedrawCursor; -#else - ChooseTargetFinish(); -#endif } /** @@ -1364,7 +1290,6 @@ global void UIHandleButtonDown(unsigned button) TheUI.SelectedViewport - TheUI.Viewports); } -#ifndef NEW_UI // to redraw the cursor immediately (and avoid up to 1 sec delay if (CursorBuilding) { // Possible Selected[0] was removed from map @@ -1407,7 +1332,6 @@ global void UIHandleButtonDown(unsigned button) } return; } -#endif if (MouseButtons & LeftButton) { // enter select mode CursorStartX = CursorX; @@ -1558,13 +1482,7 @@ global void UIHandleButtonDown(unsigned button) // } else if (ButtonAreaUnderCursor == ButtonAreaButton) { if (!GameObserve && !GamePaused) { -#ifndef NEW_UI DoButtonButtonClicked(ButtonUnderCursor); -#else - if (ButtonUnderCursor >= 0 && ButtonUnderCursor < 9) { - DoButtonButtonClicked(ButtonUnderCursor); - } -#endif } } } else if ((MouseButtons&MiddleButton)) { @@ -1744,10 +1662,8 @@ global void UIHandleButtonUp(unsigned button) if (num) { ClearStatusLine(); -#ifndef NEW_UI ClearCosts(); CurrentButtonLevel = 0; // reset unit buttons to normal -#endif SelectionChanged(); // diff --git a/src/ui/script_ui.cpp b/src/ui/script_ui.cpp index 776bcad32..f7b4f919a 100644 --- a/src/ui/script_ui.cpp +++ b/src/ui/script_ui.cpp @@ -47,22 +47,11 @@ #include "menus.h" #include "font.h" #include "etlib/hash.h" -#ifdef NEW_UI -#include "commands.h" -#include "spells.h" -#include "depend.h" -#endif /*---------------------------------------------------------------------------- -- Variables ----------------------------------------------------------------------------*/ -#ifdef NEW_UI -local SCM SelectionChangedHook; /// Script to add/remove buttons -local SCM SelectedUnitChangedHook; /// Script to refresh buttons -local SCM ChooseTargetBeginHook; /// Script to draw target selection buttons -local SCM ChooseTargetFinishHook; /// Script to draw target selection buttons -#endif global char* ClickMissile; global char* DamageMissile; @@ -70,640 +59,6 @@ global char* DamageMissile; -- Functions ----------------------------------------------------------------------------*/ -#ifdef NEW_UI -// Note, the commands all operate on the selected unit(s) and are -// called from ccl hooks during the game when a button is pressed. - -// helper functions used for actions that need target selection -global void ChooseTargetBegin(int action) -{ - CursorState = CursorStateSelect; - GameCursor = TheUI.YellowHair.Cursor; - CursorAction = action; - MustRedraw |= RedrawCursor; - - if (ChooseTargetBeginHook == NIL) { - DebugLevel0Fn("Hook is NIL!\n"); - } else { - gh_eval(ChooseTargetBeginHook, NIL); - } - // FIXME: maybe write this from ccl? - SetStatusLine("Select Target"); -} - -/** -** FIXME: docu -*/ -global void ChooseTargetFinish(void) -{ - if (CursorState != CursorStateSelect) { - return; - } - ClearStatusLine(); - CursorState = CursorStatePoint; - GameCursor = TheUI.Point.Cursor; - MustRedraw |= RedrawCursor; - CursorBuilding = 0; - - if (ChooseTargetFinishHook == NIL) { - DebugLevel0Fn("Hook is NIL!\n"); - } else { - gh_eval(ChooseTargetFinishHook, NIL); - } -} - -/** -** FIXME: docu for command-patrol -*/ -local SCM CclCommandPatrol(void) -{ - ChooseTargetBegin(ButtonPatrol); - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-harvest -*/ -local SCM CclCommandHarvest(void) -{ - ChooseTargetBegin(ButtonHarvest); - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-attack -*/ -local SCM CclCommandAttack(void) -{ - ChooseTargetBegin(ButtonAttack); - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-cancel-upgrade -*/ -local SCM CclCommandCancelUpgrade(void) -{ - if (Selected[0]->Orders[0].Action == UnitActionUpgradeTo) { - SendCommandCancelUpgradeTo(Selected[0]); - } else if (Selected[0]->Orders[0].Action == UnitActionResearch) { - SendCommandCancelResearch(Selected[0]); - } - // FIXME: must call SelectedUnitChanged() here? - return SCM_UNSPECIFIED; -} - -/** -** Build the given unit type (a building). -*/ -local SCM CclCommandBuild(SCM arg) -{ - char* ident; - UnitType* type; - - ident = gh_scm2newstr(arg, NULL); - type = UnitTypeByIdent(ident); - free(ident); - - if (!PlayerCheckUnitType(ThisPlayer, type)) { - ChooseTargetBegin(ButtonBuild); - GameCursor = TheUI.Point.Cursor; - CursorBuilding = type; - MustRedraw |= RedrawCursor; - } - - return SCM_UNSPECIFIED; -} - -/** -** Train an unit with given type -*/ -local SCM CclCommandTrainUnit(SCM arg) -{ - char* ident; - UnitType* type; - - ident = gh_scm2newstr(arg, NULL); - type = UnitTypeByIdent(ident); - free(ident); - - // FIXME: Johns: I want to place commands in queue, even if not - // FIXME: enough resources are available. - // FIXME: training queue full check is not correct for network. - // FIXME: this can be correct written, with a little more code. - if (Selected[0]->Orders[0].Action == UnitActionTrain && - (Selected[0]->Data.Train.Count == MAX_UNIT_TRAIN || - !EnableTrainingQueue)) { - NotifyPlayer(Selected[0]->Player, NotifyYellow,Selected[0]->X, - Selected[0]->Y, "Unit training queue is full"); - } else if (PlayerCheckFood(ThisPlayer, type) && - !PlayerCheckUnitType(ThisPlayer, type)) { - //PlayerSubUnitType(ThisPlayer,type); - SendCommandTrainUnit(Selected[0],type, !(KeyModifiers & ModifierShift)); - ClearStatusLine(); - } - - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-cast-spell -*/ -local SCM CclCommandCastSpell(SCM arg) -{ - int i; - char* spell_str; - SpellType * spell; - int spell_id; - - spell_str = gh_scm2newstr(arg, NULL); - spell = SpellTypeByIdent(spell_str); - spell_id = SpellIdByIdent(spell_str); - free(spell_str); - - // FIXME: maxy: make the modifiers available from ccl (and maybe - // which mouse button was pressed, too, for the action scripts) - - if (KeyModifiers & ModifierControl) { - // auto-cast the spell - int autocast; - if (!CanAutoCastSpell(spell)) { - PlayGameSound(GameSounds.PlacementError.Sound, MaxSampleVolume); - return SCM_UNSPECIFIED; - } - - autocast = 0; - // If any selected unit doesn't have autocast on turn it on - // for everyone - for (i = 0; i < NumSelected; ++i) { - if (Selected[i]->AutoCastSpell != spell) { - autocast = 1; - break; - } - } - for (i = 0; i < NumSelected; ++i) { - if (!autocast || Selected[i]->AutoCastSpell != spell) { - SendCommandAutoSpellCast(Selected[i], spell_id, autocast); - } - } - } else { - // select spell target - CursorSpell = spell_id; - ChooseTargetBegin(ButtonSpellCast); - } - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-move -*/ -local SCM CclCommandMove(void) -{ - ChooseTargetBegin(ButtonMove); - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-stop -*/ -local SCM CclCommandStop(void) -{ - int i; - - for (i = 0; i < NumSelected; ++i) { - SendCommandStopUnit(Selected[i]); - } - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-research -*/ -local SCM CclCommandResearch(SCM arg) -{ - char* what; - Upgrade* upgrade; - - what = gh_scm2newstr(arg, NULL); - upgrade = UpgradeByIdent(what); - free(what); - - if (!PlayerCheckCosts(ThisPlayer,upgrade->Costs)) { - //PlayerSubCosts(ThisPlayer,Upgrades[i].Costs); - // FIXME: key modifier check does not belong here - SendCommandResearch(Selected[0], upgrade, - !(KeyModifiers & ModifierShift)); - ClearStatusLine(); - } - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-unload -*/ -local SCM CclCommandUnload(void) -{ - ChooseTargetBegin(ButtonUnload); - return SCM_UNSPECIFIED; -} - -/** -** Build a string with unit/upgrade costs -*/ -local SCM CclGetCostString(SCM arg) -{ - char s[80]; - char* pos; - char* ident; - int i; - int* costs; - UnitType* type; - Upgrade* upgrade; - - ident = gh_scm2newstr(arg, NULL); - costs = NULL; - type = UnitTypeByIdent(ident); - if (type) { - costs = type->Stats[ThisPlayer->Player].Costs; - } else { - upgrade = UpgradeByIdent(ident); - if (upgrade) { - costs = upgrade->Costs; - } - /* TODO: mana costs - SetCosts(SpellTypeById(v)->ManaCost, 0, NULL); - */ - } - if (!costs) { - sprintf(s, "[NO COSTS: '%s']", ident); - free(ident); - return gh_str02scm(s); - } - free(ident); - - pos = s; - // do not draw time cost - for (i = 1; i < MaxCosts; ++i) { - if (costs[i]) { - pos += sprintf(pos, "$%d %d ", i, costs[i]); - } - } - return gh_str02scm(s); -} - -/** -** Check whether unit or upgrade is allowed -*/ -local SCM CclCheckAllowed(SCM arg) -{ - int allow; - char* what; - - what = gh_scm2newstr(arg, NULL); - allow = CheckDependByIdent(ThisPlayer, what); - if (allow && !strncmp(what, "upgrade-", 8)) { - allow = UpgradeIdentAllowed(ThisPlayer, what) == 'A'; - } - free(what); - return allow ? SCM_BOOL_T : SCM_BOOL_F; -} - -/** -** FIXME: docu for command-upgrade-to -*/ -local SCM CclCommandUpgradeTo(SCM arg) -{ - char* what; - UnitType* type; - - what = gh_scm2newstr(arg, NULL); - type = UnitTypeByIdent(what); - free(what); - - if (!PlayerCheckUnitType(ThisPlayer, type)) { - DebugLevel3("Upgrade to %s %d %d\n" _C_ type->Ident _C_ - type->_Costs[GoldCost] _C_ type->_Costs[WoodCost]); - // FIXME: should not check for key modifiers here - SendCommandUpgradeTo(Selected[0],type, - !(KeyModifiers & ModifierShift)); - ClearStatusLine(); - } - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-attack-ground -*/ -local SCM CclCommandAttackGround(void) -{ - ChooseTargetBegin(ButtonAttackGround); - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-return-goods -*/ -local SCM CclCommandReturnGoods(void) -{ - int i; - for (i = 0; i < NumSelected; ++i) { - // FIXME: should not check for key modifiers here - SendCommandReturnGoods(Selected[i],NoUnitP, - !(KeyModifiers & ModifierShift)); - } - return SCM_UNSPECIFIED; -} - -/** -** generic cancel command -** mainly used when in target selection mode -*/ -local SCM CclCommandCancel(void) -{ - if (CursorState == CursorStateSelect) { - ClearStatusLine(); - GameCursor = TheUI.Point.Cursor; - CursorBuilding = NULL; - CursorState = CursorStatePoint; - MustRedraw |= RedrawCursor; - } - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-cancel-build -*/ -local SCM CclCommandCancelBuilding(void) -{ - SendCommandCancelBuilding(Selected[0], - Selected[0]->Data.Builded.Worker); - ClearStatusLine(); - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-cancel-train-unit -*/ -local SCM CclCommandCancelTrainUnit(void) -{ - DebugCheck(Selected[0]->Orders[0].Action!=UnitActionTrain || - !Selected[0]->Data.Train.Count); - SendCommandCancelTraining(Selected[0], -1, NULL); - ClearStatusLine(); - // The SelectedUnitChanged hook will be called when the command - // finally got through, I hope. - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-repair -*/ -local SCM CclCommandRepair(void) -{ - ChooseTargetBegin(ButtonRepair); - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-stand-ground -*/ -local SCM CclCommandStandGround(void) -{ - int i; - - for (i = 0; i < NumSelected; ++i) { - // FIXME: key modifiers don't belong here - SendCommandStandGround(Selected[i], - !(KeyModifiers & ModifierShift)); - } - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu for command-demolish -*/ -local SCM CclCommandDemolish(void) -{ - ChooseTargetBegin(ButtonDemolish); - return SCM_UNSPECIFIED; -} - -/** -** FIXME: docu -** FIXME: a bit a confusing name, see below -*/ -local SCM CclSelectedIsBuilding(void) -{ - if (NumSelected == 0) { - return SCM_UNSPECIFIED; - } - if (Selected[0]->Type->Building) { - return SCM_BOOL_T; - } else { - return SCM_BOOL_F; - } -} - -/** -** Whether the selected unit is repairing. -*/ -local SCM CclSelectedIsRepairing(void) -{ - if (NumSelected == 0) { - return SCM_UNSPECIFIED; - } - if (Selected[0]->Orders[0].Action == UnitActionTrain) { - return SCM_BOOL_T; - } else { - return SCM_BOOL_F; - } -} - -/** -** FIXME: docu -*/ -local SCM CclSelectedIsTraining(void) -{ - if (NumSelected == 0) { - return SCM_UNSPECIFIED; - } - if (Selected[0]->Orders[0].Action == UnitActionTrain) { - return SCM_BOOL_T; - } else { - return SCM_BOOL_F; - } -} - -/** -** FIXME: docu -*/ -local SCM CclSelectedIsUpgrading(void) -{ - if (NumSelected == 0) { - return SCM_UNSPECIFIED; - } - if (Selected[0]->Orders[0].Action == UnitActionResearch || - Selected[0]->Orders[0].Action == UnitActionUpgradeTo) { - return SCM_BOOL_T; - } else { - return SCM_BOOL_F; - } -} - -/** -** FIXME: docu -*/ -local SCM CclSelectedGetRace(void) -{ - if (NumSelected == 0) { - return SCM_UNSPECIFIED; - } - DebugLevel0Fn("RaceString: %s\n" _C_ Selected[0]->Player->RaceName); - return gh_str02scm(Selected[0]->Player->RaceName); - //return gh_symbol2scm(Selected[0]->Player->RaceName); -} - -/** -** FIXME: docu -*/ -local SCM CclSelectedGetSpeed(void) -{ - if (NumSelected == 0) { - return SCM_UNSPECIFIED; - } - return gh_int2scm(Selected[0]->Stats->Speed); -} - -/** -** FIXME: docu -*/ -local SCM CclSelectedOwnedByPlayer(void) -{ - if (NumSelected == 0) { - return SCM_BOOL_F; - } - if (Selected[0]->Player == ThisPlayer) { - return SCM_BOOL_T; - } else { - return SCM_BOOL_F; - } -} - -/** -** Return the name of the resource type that is loaded. -*/ -local SCM CclSelectedResourceLoaded(void) -{ - int i; - int type; - Unit* unit; - - type = -1; - for (i = 0; i<NumSelected; ++i) { - unit = Selected[i]; - if (unit->CurrentResource && unit->Value && - (!unit->Type->ResInfo[unit->CurrentResource]->LoseResources || - unit->Value >= unit->Type->ResInfo[unit->CurrentResource]->ResourceCapacity)) { - if (type == -1) { - type = unit->CurrentResource; - } else if (type != unit->CurrentResource) { - return gh_str02scm("mixed"); - } - } - } - if (type == -1) { - return SCM_UNSPECIFIED; - } - return gh_str02scm(DefaultResourceNames[type]); -} - -/** -** FIXME: docu -*/ -local SCM CclSelectedMixedUnits(void) -{ - int i; - UnitType* type; - - if (NumSelected < 2) { - return SCM_BOOL_F; - } - - type = Selected[0]->Type; - for (i = 1; i < NumSelected; ++i) { - if (Selected[i]->Type != type) { - return SCM_BOOL_T; - } - } - return SCM_BOOL_F; -} - -/** -** FIXME: docu -*/ -local SCM CclSelectedGetAction(void) -{ - int j; - UnitAction action; - - if (NumSelected == 0) { - return gh_str02scm("Invalid"); - } - action = Selected[0]->Orders[0].Action; - for (j = 1; j < NumSelected; ++j) { - if (Selected[j]->Orders[0].Action != action) { - return gh_str02scm("Mixed"); - } - } - - switch (action) { - case UnitActionNone: return gh_str02scm("None"); - case UnitActionStill: return gh_str02scm("Still"); break; - case UnitActionStandGround: return gh_str02scm("StandGround"); break; - case UnitActionFollow: return gh_str02scm("Follow"); break; - case UnitActionMove: return gh_str02scm("Move"); break; - case UnitActionAttack: return gh_str02scm("Attack"); break; - case UnitActionAttackGround: return gh_str02scm("AttackGround"); break; - case UnitActionDie: return gh_str02scm("Die"); break; - case UnitActionSpellCast: return gh_str02scm("SpellCast"); break; - case UnitActionTrain: return gh_str02scm("Train"); break; - case UnitActionUpgradeTo: return gh_str02scm("UpgradeTo"); break; - case UnitActionResearch: return gh_str02scm("Research"); break; - case UnitActionBuilded: return gh_str02scm("Builded"); break; - case UnitActionBoard: return gh_str02scm("Board"); break; - case UnitActionUnload: return gh_str02scm("Unload"); break; - case UnitActionPatrol: return gh_str02scm("Patrol"); break; - case UnitActionBuild: return gh_str02scm("Build"); break; - case UnitActionRepair: return gh_str02scm("Repair"); break; - case UnitActionResource: return gh_str02scm("Resource"); break; - case UnitActionReturnGoods: return gh_str02scm("ReturnGoods"); break; - case UnitActionDemolish: return gh_str02scm("Demolish"); break; - default: - DebugLevel0Fn("FIXME: invalid action id %d\n" _C_ action); - return gh_str02scm("invalid"); - } -} - -/** -** FIXME: docu -*/ -local SCM CclSelectedDrawButtons(void) -{ - if (NumSelected > 0) { - if (Selected[0]->Type->AddButtonsHook == NIL) { - DebugLevel0Fn("Hook is NIL!\n"); - } else { - /* - DebugLevel0Fn("Running hook:\n"); - gh_display(Selected[0]->Type->AddButtonsHook); - gh_newline(); - */ - gh_eval(Selected[0]->Type->AddButtonsHook, NIL); - } - } - return SCM_UNSPECIFIED; -} -#endif /** ** Enable/disable the global color cycling. @@ -2149,11 +1504,7 @@ local SCM CclSetShowCommandKey(SCM flag) old = ShowCommandKey; ShowCommandKey = gh_scm2bool(flag); -#ifndef NEW_UI UpdateButtonPanel(); -#else - MustRedraw |= RedrawButtonPanel; -#endif return gh_bool2scm(old); } @@ -3084,7 +2435,6 @@ local SCM CclDefineMenuGraphics(SCM list) return SCM_UNSPECIFIED; } -#ifndef NEW_UI /** ** Define a button. ** @@ -3281,184 +2631,14 @@ local SCM CclDefineButton(SCM list) return SCM_UNSPECIFIED; } -#else -/** -** Define a button. -** -** FIXME: need some general data structure to make this parsing easier. -** -** @param list List describing the button. -*/ -local SCM CclAddButton(SCM list) -{ - SCM value; - char* s1; - int pos; - ButtonAction ba; - - pos = -1; - - //DebugLevel3Fn("Add button\n"); - DebugLevel0Fn("Add button\n"); - - memset(&ba, 0, sizeof(ba)); - // - // Parse the arguments, already the new tagged format. - // - while (!gh_null_p(list)) { - value = gh_car(list); - list = gh_cdr(list); - if (gh_eq_p(value, gh_symbol2scm("pos"))) { - value = gh_car(list); - list = gh_cdr(list); - pos = gh_scm2int(value); - } else if (gh_eq_p(value, gh_symbol2scm("icon"))) { - value = gh_car(list); - list = gh_cdr(list); - ba.Icon.Name = gh_scm2newstr(value, NULL); - } else if (gh_eq_p(value, gh_symbol2scm("action"))) { - value = gh_car(list); - list = gh_cdr(list); - // Protect the action script against the garbage collector - CclGcProtect(value); - ba.Action = value; - } else if (gh_eq_p(value, gh_symbol2scm("key"))) { - value = gh_car(list); - list = gh_cdr(list); - s1 = gh_scm2newstr(value, NULL); - ba.Key = *s1; - free(s1); - } else if (gh_eq_p(value, gh_symbol2scm("highlight"))) { - value = gh_car(list); - list = gh_cdr(list); - ba.Highlight = gh_scm2bool(value); - } else if (gh_eq_p(value, gh_symbol2scm("hint"))) { - value = gh_car(list); - list = gh_cdr(list); - ba.Hint = gh_scm2newstr(value, NULL); - } else { - s1 = gh_scm2newstr(value, NULL); - fprintf(stderr, "Unsupported tag %s\n", s1); - free(s1); - } - } - - - // maxy: allocated memory goes into currentButtons[], must not be freed - AddButton(pos, ba.Icon.Name, ba.Action, ba.Key, ba.Hint, ba.Highlight); - - return SCM_UNSPECIFIED; -} - -/** -** Remove all displayed buttons from the command panel. -*/ -local SCM CclRemoveAllButtons(void) -{ - CleanButtons(); - return SCM_UNSPECIFIED; -} - -/** -** Remove a single button from the command panel. -** -** @param id The button number. -*/ -local SCM CclRemoveButton(SCM id) -{ - RemoveButton(gh_scm2int(id)); - return SCM_UNSPECIFIED; -} - -/** -** Set the hook called when the ui enters "set-destination" mode -** -** @param script The script to run. -*/ -local SCM CclSetChooseTargetBeginHook(SCM script) -{ - if (ChooseTargetBeginHook) { - CclGcUnprotect(ChooseTargetBeginHook); - } - CclGcProtect(script); - ChooseTargetBeginHook = script; - return SCM_UNSPECIFIED; -} - -/** -** Set the hook called when the ui leaves "set-destination" mode -** -** @param script The script to run. -*/ -local SCM CclSetChooseTargetFinishHook(SCM script) -{ - if (ChooseTargetFinishHook) { - CclGcUnprotect(ChooseTargetFinishHook); - } - CclGcProtect(script); - ChooseTargetFinishHook = script; - return SCM_UNSPECIFIED; -} - -/** -** Set the hook called when the units selection was changed. -** -** @param script The script to run. -*/ -local SCM CclSetSelectionChangedHook(SCM script) -{ - if (SelectionChangedHook) { - CclGcUnprotect(SelectionChangedHook); - } - CclGcProtect(script); - SelectionChangedHook = script; - return SCM_UNSPECIFIED; -} - -/** -** Set the hook when the selected unit was updated. -** -** @param script The script to run. -*/ -local SCM CclSetSelectedUnitChangedHook(SCM script) -{ - if (SelectedUnitChangedHook) { - CclGcUnprotect(SelectedUnitChangedHook); - } - CclGcProtect(script); - SelectedUnitChangedHook = script; - return SCM_UNSPECIFIED; -} -#endif /** ** Run the set-selection-changed-hook. */ global void SelectionChanged(void) { -#ifndef NEW_UI UpdateButtonPanel(); MustRedraw |= RedrawInfoPanel; -#else - // could be in the middle of choosing a place to build when a - // worker gets killed - ChooseTargetFinish(); - - if (!GameRunning) { - return; - } - DebugLevel0Fn("Calling the selection-changed-hook.\n"); - if (!gh_null_p(SelectionChangedHook)) { - //if ([ccl debugging]) { // display executed command - gh_display(SelectionChangedHook); - gh_newline(); - //} - gh_eval(SelectionChangedHook, NIL); - } else { - DebugLevel0Fn("Hook empty!\n"); - } - MustRedraw |= RedrawInfoPanel; -#endif } /** @@ -3466,24 +2646,7 @@ global void SelectionChanged(void) */ global void SelectedUnitChanged(void) { -#ifndef NEW_UI UpdateButtonPanel(); -#else - DebugLevel0Fn("Calling the selected-unit-changed-hook.\n"); - if (!GameRunning) { - return; - } - if (!gh_null_p(SelectionChangedHook)) { - //if ([ccl debugging]) { // display executed command - //gh_display(gh_car(SelectedUnitChangedHook)); - //gh_display(SelectedUnitChangedHook); - //gh_newline(); - //} - gh_eval(SelectedUnitChangedHook, NIL); - } else { - DebugLevel0Fn("Hook empty!\n"); - } -#endif } /** @@ -3823,17 +2986,7 @@ global void UserInterfaceCclRegister(void) gh_new_procedure0_0("right-button-moves", CclRightButtonMoves); gh_new_procedure1_0("set-fancy-buildings!", CclSetFancyBuildings); -#ifndef NEW_UI gh_new_procedureN("define-button", CclDefineButton); -#else - gh_new_procedure1_0("set-selection-changed-hook", CclSetSelectionChangedHook); - gh_new_procedure1_0("set-selected-unit-changed-hook", CclSetSelectedUnitChangedHook); - gh_new_procedure1_0("set-choose-target-begin-hook", CclSetChooseTargetBeginHook); - gh_new_procedure1_0("set-choose-target-finish-hook", CclSetChooseTargetFinishHook); - gh_new_procedureN("add-button", CclAddButton); - gh_new_procedure1_0("remove-button", CclRemoveButton); - gh_new_procedure0_0("remove-all-buttons", CclRemoveAllButtons); -#endif gh_new_procedureN("define-menu-item", CclDefineMenuItem); gh_new_procedureN("define-menu", CclDefineMenu); @@ -3870,50 +3023,6 @@ global void UserInterfaceCclRegister(void) gh_new_procedure0_0("reset-keystroke-help", CclResetKeystrokeHelp); gh_new_procedureN("add-keystroke-help", CclAddKeystrokeHelp); -#ifdef NEW_UI - // - // Commands for buttons - // - gh_new_procedure0_0("command-patrol", CclCommandPatrol); - gh_new_procedure0_0("command-harvest", CclCommandHarvest); - gh_new_procedure0_0("command-attack", CclCommandAttack); - gh_new_procedure0_0("command-cancel-upgrade", CclCommandCancelUpgrade); - gh_new_procedure1_0("command-build", CclCommandBuild); - gh_new_procedure1_0("command-train-unit", CclCommandTrainUnit); - gh_new_procedure1_0("command-cast-spell", CclCommandCastSpell); - gh_new_procedure0_0("command-move", CclCommandMove); - gh_new_procedure0_0("command-stop", CclCommandStop); - gh_new_procedure1_0("command-research", CclCommandResearch); - gh_new_procedure0_0("command-unload", CclCommandUnload); - gh_new_procedure1_0("command-upgrade-to", CclCommandUpgradeTo); - gh_new_procedure0_0("command-attack-ground", CclCommandAttackGround); - gh_new_procedure0_0("command-return-goods", CclCommandReturnGoods); - gh_new_procedure0_0("command-cancel", CclCommandCancel); - gh_new_procedure0_0("command-cancel-building", CclCommandCancelBuilding); - gh_new_procedure0_0("command-cancel-train-unit", CclCommandCancelTrainUnit); - gh_new_procedure0_0("command-repair", CclCommandRepair); - gh_new_procedure0_0("command-stand-ground", CclCommandStandGround); - gh_new_procedure0_0("command-demolish", CclCommandDemolish); - - gh_new_procedure1_0("check-allowed", CclCheckAllowed); - gh_new_procedure1_0("get-cost-string", CclGetCostString); - - // - // FIXME: make those functions use an unit handle instead - // and add (get-selected-unit). - // - gh_new_procedure0_0("selected-is-building", CclSelectedIsBuilding); - gh_new_procedure0_0("selected-is-training", CclSelectedIsTraining); - gh_new_procedure0_0("selected-is-upgrading", CclSelectedIsUpgrading); - gh_new_procedure0_0("selected-get-race", CclSelectedGetRace); - gh_new_procedure0_0("selected-get-speed", CclSelectedGetSpeed); - gh_new_procedure0_0("selected-owned-by-player", CclSelectedOwnedByPlayer); - gh_new_procedure0_0("selected-mixed-units", CclSelectedMixedUnits); - gh_new_procedure0_0("selected-get-action", CclSelectedGetAction); - gh_new_procedure0_0("selected-resource-loaded", CclSelectedResourceLoaded); - gh_new_procedure0_0("selected-draw-buttons", CclSelectedDrawButtons); - -#endif InitMenuFuncHash(); } diff --git a/src/unit/script_unittype.cpp b/src/unit/script_unittype.cpp index 489a745b1..f97ff12ad 100644 --- a/src/unit/script_unittype.cpp +++ b/src/unit/script_unittype.cpp @@ -128,9 +128,6 @@ local SCM CclDefineUnitType(SCM list) type->_RegenerationRate = 0; } type->NumDirections = 8; -#ifdef NEW_UI - type->AddButtonsHook = NIL; -#endif // // Parse the list: (still everything could be changed!) @@ -596,13 +593,6 @@ local SCM CclDefineUnitType(SCM list) errl("Unsupported sound tag", value); } } -#ifdef NEW_UI - } else if (gh_eq_p(value, gh_symbol2scm("add-buttons"))) { - value = gh_car(list); - list = gh_cdr(list); - CclGcProtect(value); - type->AddButtonsHook = value; -#endif } else { // FIXME: this leaves a half initialized unit-type printf("\n%s\n",type->Name); diff --git a/src/unit/unit.cpp b/src/unit/unit.cpp index b7b33aa09..969bd2fb1 100644 --- a/src/unit/unit.cpp +++ b/src/unit/unit.cpp @@ -635,12 +635,10 @@ global void RemoveUnit(Unit* unit, Unit* host) unit->Removed=1; // Remove unit from the current selection if( unit->Selected ) { -#ifndef NEW_UI if( NumSelected==1 ) { // Remove building cursor CancelBuildingMode(); } MustRedraw|=RedrawPanels; -#endif UnSelectUnit(unit); SelectionChanged(); } diff --git a/src/unit/unittype.cpp b/src/unit/unittype.cpp index f323d447c..1cd377ff1 100644 --- a/src/unit/unittype.cpp +++ b/src/unit/unittype.cpp @@ -1050,11 +1050,6 @@ local void SaveUnitType(CLFile* file, const UnitType* type, int all) CLprintf(file, " 'teleporter\n"); } -#ifdef NEW_UI - CLprintf(file, " 'add-buttons '"); - lprin1CL(type->AddButtonsHook, file); - CLprintf(file, "\n"); -#endif CLprintf(file, " 'sounds '("); if (type->Sound.Selected.Name) { diff --git a/src/video/cursor.cpp b/src/video/cursor.cpp index 127b8cbd7..6324d7975 100644 --- a/src/video/cursor.cpp +++ b/src/video/cursor.cpp @@ -74,11 +74,7 @@ global CursorType* Cursors; global CursorStates CursorState;/// current cursor state (point,...) global int CursorAction; /// action for selection -#ifndef NEW_UI global int CursorValue; /// value for CursorAction (spell type f.e.) -#else -global int CursorSpell; /// spell type while selecting target -#endif //Event changed mouse position, can alter at any moment global int CursorX; /// cursor position on screen X @@ -1150,11 +1146,7 @@ global void SaveCursors(CLFile* file) break; } CLprintf(file, ";;(cursor-action %d)\n", CursorAction); -#ifndef NEW_UI CLprintf(file, ";;(cursor-value %d)\n", CursorValue); -#else - CLprintf(file, ";;(cursor-spell %d)\n", CursorSpell); -#endif CLprintf(file, ";;(cursor-building '%s)\n", CursorBuilding ? CursorBuilding->Ident : "()"); CLprintf(file, ";;(cursor-position '(%d %d)\n", CursorX, CursorY);