2222#include " ../Interface/Text.h"
2323#include " ../Interface/TextList.h"
2424#include " ../Interface/ArrowButton.h"
25+ #include " ../Engine/Action.h"
2526#include " ../Engine/Game.h"
2627#include " ../Engine/Language.h"
2728#include " ../Engine/Palette.h"
@@ -145,18 +146,22 @@ void ManufactureInfoState::buildUi()
145146 _btnEngineerUp->setColor (Palette::blockOffset (15 )+1 );
146147 _btnEngineerUp->onMousePress ((ActionHandler)&ManufactureInfoState::moreEngineerPress);
147148 _btnEngineerUp->onMouseRelease ((ActionHandler)&ManufactureInfoState::moreEngineerRelease);
149+ _btnEngineerUp->onMouseClick ((ActionHandler)&ManufactureInfoState::moreEngineerClick, 0 );
148150
149151 _btnEngineerDown->setColor (Palette::blockOffset (15 )+1 );
150152 _btnEngineerDown->onMousePress ((ActionHandler)&ManufactureInfoState::lessEngineerPress);
151153 _btnEngineerDown->onMouseRelease ((ActionHandler)&ManufactureInfoState::lessEngineerRelease);
154+ _btnEngineerDown->onMouseClick ((ActionHandler)&ManufactureInfoState::lessEngineerClick, 0 );
152155
153156 _btnUnitUp->setColor (Palette::blockOffset (15 )+1 );
154157 _btnUnitUp->onMousePress ((ActionHandler)&ManufactureInfoState::moreUnitPress);
155158 _btnUnitUp->onMouseRelease ((ActionHandler)&ManufactureInfoState::moreUnitRelease);
159+ _btnUnitUp->onMouseClick ((ActionHandler)&ManufactureInfoState::moreUnitClick, 0 );
156160
157161 _btnUnitDown->setColor (Palette::blockOffset (15 )+1 );
158162 _btnUnitDown->onMousePress ((ActionHandler)&ManufactureInfoState::lessUnitPress);
159163 _btnUnitDown->onMouseRelease ((ActionHandler)&ManufactureInfoState::lessUnitRelease);
164+ _btnUnitDown->onMouseClick ((ActionHandler)&ManufactureInfoState::lessUnitClick, 0 );
160165
161166 _txtUnitUp->setColor (Palette::blockOffset (15 )+1 );
162167 _txtUnitUp->setText (_game->getLanguage ()->getString (" STR_INCREASE_UC" ));
@@ -249,7 +254,7 @@ void ManufactureInfoState::setAssignedEngineer()
249254*/
250255void ManufactureInfoState::moreEngineerPress (Action * action)
251256{
252- _timerMoreEngineer->start ();
257+ if (action-> getDetails ()-> button . button == SDL_BUTTON_LEFT ) _timerMoreEngineer->start ();
253258}
254259
255260/* *
@@ -258,7 +263,28 @@ void ManufactureInfoState::moreEngineerPress(Action * action)
258263*/
259264void ManufactureInfoState::moreEngineerRelease (Action * action)
260265{
261- _timerMoreEngineer->stop ();
266+ if (action->getDetails ()->button .button == SDL_BUTTON_LEFT ) _timerMoreEngineer->stop ();
267+ }
268+
269+ /* *
270+ * Allocate all engineers
271+ * @param action a pointer to an Action
272+ */
273+ void ManufactureInfoState::moreEngineerClick (Action * action)
274+ {
275+ if (action->getDetails ()->button .button == SDL_BUTTON_RIGHT )
276+ {
277+ int assigned = _production->getAssignedEngineers ();
278+ int availableEngineer = _base->getAvailableEngineers ();
279+ int availableWorkSpace = _base->getFreeWorkshops ();
280+ if (availableEngineer > 0 && availableWorkSpace > 0 )
281+ {
282+ int change=std::min (availableEngineer, availableWorkSpace);
283+ _production->setAssignedEngineers (assigned+=change);
284+ _base->setEngineers (_base->getEngineers ()-change);
285+ setAssignedEngineer ();
286+ }
287+ }
262288}
263289
264290/* *
@@ -267,7 +293,7 @@ void ManufactureInfoState::moreEngineerRelease(Action * action)
267293*/
268294void ManufactureInfoState::lessEngineerPress (Action * action)
269295{
270- _timerLessEngineer->start ();
296+ if (action-> getDetails ()-> button . button == SDL_BUTTON_LEFT ) _timerLessEngineer->start ();
271297}
272298
273299/* *
@@ -276,7 +302,25 @@ void ManufactureInfoState::lessEngineerPress(Action * action)
276302*/
277303void ManufactureInfoState::lessEngineerRelease (Action * action)
278304{
279- _timerLessEngineer->stop ();
305+ if (action->getDetails ()->button .button == SDL_BUTTON_LEFT ) _timerLessEngineer->stop ();
306+ }
307+
308+ /* *
309+ * Allocate 0 engineers
310+ * @param action a pointer to an Action
311+ */
312+ void ManufactureInfoState::lessEngineerClick (Action * action)
313+ {
314+ if (action->getDetails ()->button .button == SDL_BUTTON_RIGHT )
315+ {
316+ int assigned = _production->getAssignedEngineers ();
317+ if (assigned > 0 )
318+ {
319+ _production->setAssignedEngineers (0 );
320+ _base->setEngineers (_base->getEngineers ()+assigned);
321+ setAssignedEngineer ();
322+ }
323+ }
280324}
281325
282326/* *
@@ -285,7 +329,7 @@ void ManufactureInfoState::lessEngineerRelease(Action * action)
285329*/
286330void ManufactureInfoState::moreUnitPress (Action * action)
287331{
288- _timerMoreUnit->start ();
332+ if (action-> getDetails ()-> button . button == SDL_BUTTON_LEFT ) _timerMoreUnit->start ();
289333}
290334
291335/* *
@@ -294,7 +338,36 @@ void ManufactureInfoState::moreUnitPress(Action * action)
294338*/
295339void ManufactureInfoState::moreUnitRelease (Action * action)
296340{
297- _timerMoreUnit->stop ();
341+ if (action->getDetails ()->button .button == SDL_BUTTON_LEFT ) _timerMoreUnit->stop ();
342+ }
343+
344+ /* *
345+ * This could set a virtual infinite value for units
346+ * which could mean produce & sell automatically just like in UFOextender. :)
347+ * Perhaps someone will implement that feature later.
348+ * @param action a pointer to an Action
349+ */
350+ void ManufactureInfoState::moreUnitClick (Action * action)
351+ {
352+ if (action->getDetails ()->button .button == SDL_BUTTON_RIGHT )
353+ {
354+ // TODO: virtual infinite value for produce & sell automatically
355+ // now it just raises the value to 999 or max-available-hangars on crafts
356+ int more = _production->getAmountRemaining ();
357+ if (_production->getRules ()->getCategory () == " STR_CRAFT" )
358+ {
359+ if (_base->getAvailableHangars () - _base->getUsedHangars () > 0 )
360+ {
361+ _production->setAmountRemaining (std::max (more,_base->getAvailableHangars () - _base->getUsedHangars ()));
362+ setAssignedEngineer ();
363+ }
364+ }
365+ else
366+ {
367+ _production->setAmountRemaining (std::max (more,999 ));
368+ setAssignedEngineer ();
369+ }
370+ }
298371}
299372
300373/* *
@@ -303,7 +376,7 @@ void ManufactureInfoState::moreUnitRelease(Action * action)
303376*/
304377void ManufactureInfoState::lessUnitPress (Action * action)
305378{
306- _timerLessUnit->start ();
379+ if (action-> getDetails ()-> button . button == SDL_BUTTON_LEFT ) _timerLessUnit->start ();
307380}
308381
309382/* *
@@ -312,7 +385,24 @@ void ManufactureInfoState::lessUnitPress(Action * action)
312385*/
313386void ManufactureInfoState::lessUnitRelease (Action * action)
314387{
315- _timerLessUnit->stop ();
388+ if (action->getDetails ()->button .button == SDL_BUTTON_LEFT ) _timerLessUnit->stop ();
389+ }
390+
391+ /* *
392+ * Build no more unit
393+ * @param action a pointer to an Action
394+ */
395+ void ManufactureInfoState::lessUnitClick (Action * action)
396+ {
397+ if (action->getDetails ()->button .button == SDL_BUTTON_RIGHT )
398+ {
399+ int less = _production->getAmountRemaining ();
400+ if (less > (_production->getAmountProduced () + 1 ))
401+ {
402+ _production->setAmountRemaining (_production->getAmountProduced () + 1 );
403+ setAssignedEngineer ();
404+ }
405+ }
316406}
317407
318408/* *
0 commit comments