diff --git a/Core/GameEngine/CMakeLists.txt b/Core/GameEngine/CMakeLists.txt index eff13029517..af39c615d37 100644 --- a/Core/GameEngine/CMakeLists.txt +++ b/Core/GameEngine/CMakeLists.txt @@ -142,7 +142,7 @@ set(GAMEENGINE_SRC Include/Common/XferLoad.h Include/Common/XferSave.h Include/GameClient/Anim2D.h -# Include/GameClient/AnimateWindowManager.h + Include/GameClient/AnimateWindowManager.h # Include/GameClient/CampaignManager.h Include/GameClient/ChallengeGenerals.h Include/GameClient/ClientInstance.h @@ -184,8 +184,8 @@ set(GAMEENGINE_SRC Include/GameClient/GameText.h Include/GameClient/GameWindow.h Include/GameClient/GameWindowGlobal.h -# Include/GameClient/GameWindowID.h -# Include/GameClient/GameWindowManager.h + Include/GameClient/GameWindowID.h + Include/GameClient/GameWindowManager.h Include/GameClient/GameWindowTransitions.h Include/GameClient/GlobalLanguage.h Include/GameClient/GraphDraw.h @@ -711,7 +711,7 @@ set(GAMEENGINE_SRC Source/GameClient/GameText.cpp Source/GameClient/GlobalLanguage.cpp Source/GameClient/GraphDraw.cpp -# Source/GameClient/GUI/AnimateWindowManager.cpp + Source/GameClient/GUI/AnimateWindowManager.cpp Source/GameClient/GUI/ChallengeGenerals.cpp Source/GameClient/GUI/ControlBar/ControlBar.cpp Source/GameClient/GUI/ControlBar/ControlBarBeacon.cpp @@ -741,10 +741,10 @@ set(GAMEENGINE_SRC Source/GameClient/GUI/GameFont.cpp Source/GameClient/GUI/GameWindow.cpp Source/GameClient/GUI/GameWindowGlobal.cpp -# Source/GameClient/GUI/GameWindowManager.cpp -# Source/GameClient/GUI/GameWindowManagerScript.cpp + Source/GameClient/GUI/GameWindowManager.cpp + Source/GameClient/GUI/GameWindowManagerScript.cpp Source/GameClient/GUI/GameWindowTransitions.cpp -# Source/GameClient/GUI/GameWindowTransitionsStyles.cpp + Source/GameClient/GUI/GameWindowTransitionsStyles.cpp Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/AnimateWindowManager.h b/Core/GameEngine/Include/GameClient/AnimateWindowManager.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/AnimateWindowManager.h rename to Core/GameEngine/Include/GameClient/AnimateWindowManager.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowID.h b/Core/GameEngine/Include/GameClient/GameWindowID.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowID.h rename to Core/GameEngine/Include/GameClient/GameWindowID.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowManager.h b/Core/GameEngine/Include/GameClient/GameWindowManager.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowManager.h rename to Core/GameEngine/Include/GameClient/GameWindowManager.h diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp b/Core/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp rename to Core/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp b/Core/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp rename to Core/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp b/Core/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp rename to Core/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitionsStyles.cpp b/Core/GameEngine/Source/GameClient/GUI/GameWindowTransitionsStyles.cpp similarity index 97% rename from GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitionsStyles.cpp rename to Core/GameEngine/Source/GameClient/GUI/GameWindowTransitionsStyles.cpp index a778379dcbb..2e188ff5797 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitionsStyles.cpp +++ b/Core/GameEngine/Source/GameClient/GUI/GameWindowTransitionsStyles.cpp @@ -66,6 +66,24 @@ // DEFINES //////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- static void drawTypeText( GameWindow *window, DisplayString *str); + +static Color getFlashTransitionColor( UnsignedByte alpha ) +{ +#if RTS_GENERALS + return GameMakeColor( 255, 203, 45, alpha ); +#elif RTS_ZEROHOUR + return GameMakeColor( 255, 255, 255, alpha ); +#endif +} + +static Color getFullFadeTransitionColor( UnsignedByte alpha ) +{ +#if RTS_GENERALS + return GameMakeColor( 255, 190, 0, alpha ); +#elif RTS_ZEROHOUR + return GameMakeColor( 60, 60, 180, alpha ); +#endif +} //----------------------------------------------------------------------------- // PUBLIC FUNCTIONS /////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -185,44 +203,44 @@ void FlashTransition::draw() { case FLASHTRANSITION_FADE_IN_1: { - TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, GameMakeColor(255, 255, 255,100)); - TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, GameMakeColor(255, 255, 255, 33)); + TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, getFlashTransitionColor( 100 )); + TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, getFlashTransitionColor( 33 )); } break; case FLASHTRANSITION_FADE_IN_2: { - TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, GameMakeColor(255, 255, 255,150)); - TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, GameMakeColor(255, 255, 255, 66)); + TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, getFlashTransitionColor( 150 )); + TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, getFlashTransitionColor( 66 )); } break; case FLASHTRANSITION_FADE_IN_3: { - TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, GameMakeColor(255, 255, 255,200)); - TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, GameMakeColor(255, 255, 255, 99)); + TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, getFlashTransitionColor( 200 )); + TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, getFlashTransitionColor( 99 )); } break; case FLASHTRANSITION_FADE_TO_BACKGROUND_1: { - TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, GameMakeColor(255, 255, 255,250)); - TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, GameMakeColor(255, 255, 255, 75)); + TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, getFlashTransitionColor( 250 )); + TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, getFlashTransitionColor( 75 )); } break; case FLASHTRANSITION_FADE_TO_BACKGROUND_2: { - TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, GameMakeColor(255, 255, 255,250)); - TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, GameMakeColor(255, 255, 255,50)); + TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, getFlashTransitionColor( 250 )); + TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, getFlashTransitionColor( 50 )); } break; case FLASHTRANSITION_FADE_TO_BACKGROUND_3: { - TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, GameMakeColor(255, 255, 255,250)); - TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, GameMakeColor(255, 255, 255, 25)); + TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, getFlashTransitionColor( 250 )); + TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, getFlashTransitionColor( 25 )); } break; case FLASHTRANSITION_FADE_TO_BACKGROUND_4: { - TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, GameMakeColor(255, 255, 255,250)); - TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, GameMakeColor(255, 255, 255, 10)); + TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, getFlashTransitionColor( 250 )); + TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, getFlashTransitionColor( 10 )); } break; } @@ -503,50 +521,50 @@ void ButtonFlashTransition::draw() case BUTTONFLASHTRANSITION_FADE_IN_1: { //PushButtonImageDrawThree(m_win, 100); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, GameMakeColor(255, 255, 255,100)); - TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, GameMakeColor(255, 255, 255, 75)); + TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, getFlashTransitionColor( 100 )); + TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, getFlashTransitionColor( 75 )); } break; case BUTTONFLASHTRANSITION_FADE_IN_2: { //PushButtonImageDrawThree(m_win, 150); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, GameMakeColor(255, 255, 255,150)); - TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, GameMakeColor(255, 255, 255, 150)); + TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, getFlashTransitionColor( 150 )); + TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, getFlashTransitionColor( 150 )); } break; case BUTTONFLASHTRANSITION_FADE_IN_3: { //PushButtonImageDrawThree(m_win, 200); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, GameMakeColor(255, 255, 255,200)); - TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, GameMakeColor(255, 255, 255, 200)); + TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, getFlashTransitionColor( 200 )); + TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, getFlashTransitionColor( 200 )); } break; case BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_1: { PushButtonImageDrawThree(m_win, 255); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, GameMakeColor(255, 255, 255,250)); - TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, GameMakeColor(255, 255, 255, 150)); + TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, getFlashTransitionColor( 250 )); + TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, getFlashTransitionColor( 150 )); } break; case BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_2: { PushButtonImageDrawThree(m_win, 255); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, GameMakeColor(255, 255, 255,250)); - TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, GameMakeColor(255, 255, 255,100)); + TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, getFlashTransitionColor( 250 )); + TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, getFlashTransitionColor( 100 )); } break; case BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_3: { PushButtonImageDrawThree(m_win, 255); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, GameMakeColor(255, 255, 255,250)); - TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, GameMakeColor(255, 255, 255, 50)); + TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, getFlashTransitionColor( 250 )); + TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, getFlashTransitionColor( 50 )); } break; case BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_4: { PushButtonImageDrawThree(m_win, 255); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, GameMakeColor(255, 255, 255,250)); - TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, GameMakeColor(255, 255, 255, 15)); + TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, getFlashTransitionColor( 250 )); + TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, getFlashTransitionColor( 15 )); } break; case BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_1: @@ -1876,7 +1894,7 @@ void FullFadeTransition::draw() if(alpha > 255) alpha = 255; TheDisplay->drawFillRect(m_pos.x, m_pos.y, m_size.x, m_size.y , GameMakeColor(0,0,0,alpha)); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y, m_size.x, m_size.y , 1.0f, GameMakeColor(60,60,180,alpha)); + TheDisplay->drawOpenRect(m_pos.x, m_pos.y, m_size.x, m_size.y , 1.0f, getFullFadeTransitionColor( alpha )); } void FullFadeTransition::skip() diff --git a/Generals/Code/GameEngine/CMakeLists.txt b/Generals/Code/GameEngine/CMakeLists.txt index 0db74569602..5ba4b5f62a5 100644 --- a/Generals/Code/GameEngine/CMakeLists.txt +++ b/Generals/Code/GameEngine/CMakeLists.txt @@ -129,7 +129,7 @@ set(GAMEENGINE_SRC # Include/Common/XferLoad.h # Include/Common/XferSave.h # Include/GameClient/Anim2D.h - Include/GameClient/AnimateWindowManager.h +# Include/GameClient/AnimateWindowManager.h # Include/GameClient/ChallengeGenerals.h Include/GameClient/CampaignManager.h # Include/GameClient/ClientInstance.h @@ -171,8 +171,8 @@ set(GAMEENGINE_SRC # Include/GameClient/GameText.h # Include/GameClient/GameWindow.h # Include/GameClient/GameWindowGlobal.h - Include/GameClient/GameWindowID.h - Include/GameClient/GameWindowManager.h +# Include/GameClient/GameWindowID.h +# Include/GameClient/GameWindowManager.h # Include/GameClient/GameWindowTransitions.h # Include/GameClient/GlobalLanguage.h # Include/GameClient/GraphDraw.h @@ -653,7 +653,7 @@ set(GAMEENGINE_SRC # Source/GameClient/GameText.cpp # Source/GameClient/GlobalLanguage.cpp # Source/GameClient/GraphDraw.cpp - Source/GameClient/GUI/AnimateWindowManager.cpp +# Source/GameClient/GUI/AnimateWindowManager.cpp # Source/GameClient/GUI/ChallengeGenerals.cpp # Source/GameClient/GUI/ControlBar/ControlBar.cpp # Source/GameClient/GUI/ControlBar/ControlBarBeacon.cpp @@ -683,10 +683,10 @@ set(GAMEENGINE_SRC # Source/GameClient/GUI/GameFont.cpp # Source/GameClient/GUI/GameWindow.cpp # Source/GameClient/GUI/GameWindowGlobal.cpp - Source/GameClient/GUI/GameWindowManager.cpp - Source/GameClient/GUI/GameWindowManagerScript.cpp +# Source/GameClient/GUI/GameWindowManager.cpp +# Source/GameClient/GUI/GameWindowManagerScript.cpp # Source/GameClient/GUI/GameWindowTransitions.cpp - Source/GameClient/GUI/GameWindowTransitionsStyles.cpp +# Source/GameClient/GUI/GameWindowTransitionsStyles.cpp # Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp # Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp # Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp diff --git a/Generals/Code/GameEngine/Include/GameClient/AnimateWindowManager.h b/Generals/Code/GameEngine/Include/GameClient/AnimateWindowManager.h deleted file mode 100644 index 4452cb3bad3..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/AnimateWindowManager.h +++ /dev/null @@ -1,235 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** 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 3 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, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: AnimateWindowManager.h ///////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Electronic Arts Pacific. -// -// Confidential Information -// Copyright (C) 2002 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// created: Mar 2002 -// -// Filename: AnimateWindowManager.h -// -// author: Chris Huybregts -// -// purpose: The Animate Window class will be used by registering a window with -// the manager with stating what kind of animation to do. Then on every -// update, we'll move the windows. -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -//----------------------------------------------------------------------------- -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// USER INCLUDES ////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -#include "Lib/BaseType.h" -#include "Common/SubsystemInterface.h" -#include "Common/GameMemory.h" - -//----------------------------------------------------------------------------- -// FORWARD REFERENCES ///////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -class GameWindow; -class ProcessAnimateWindowSlideFromBottom; -class ProcessAnimateWindowSlideFromBottomTimed; -class ProcessAnimateWindowSlideFromTop; -class ProcessAnimateWindowSlideFromLeft; -class ProcessAnimateWindowSlideFromRight; -class ProcessAnimateWindowSlideFromRightFast; -class ProcessAnimateWindowSpiral; -class ProcessAnimateWindowSlideFromTopFast; -class ProcessAnimateWindowSideSelect; -class ProcessAnimateWindow; - -//----------------------------------------------------------------------------- -// TYPE DEFINES /////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -enum AnimTypes CPP_11(: Int) -{ - WIN_ANIMATION_NONE = 0, - WIN_ANIMATION_SLIDE_RIGHT, - WIN_ANIMATION_SLIDE_RIGHT_FAST, - WIN_ANIMATION_SLIDE_LEFT, - WIN_ANIMATION_SLIDE_TOP, - WIN_ANIMATION_SLIDE_BOTTOM, - WIN_ANIMATION_SPIRAL, - WIN_ANIMATION_SLIDE_BOTTOM_TIMED, - WIN_ANIMATION_SLIDE_TOP_FAST, - WIN_ANIMATION_COUNT -} ; - -//----------------------------------------------------------------------------- -// TheSuperHackers @build xezon 14/03/2025 Puts class into namespace to avoid name collision with AnimateWindow function in WinUser.h -namespace wnd -{ -class AnimateWindow : public MemoryPoolObject -{ - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(AnimateWindow, "AnimateWindow") -public: - AnimateWindow(); - //~AnimateWindow(); - - static AnimateWindow* createNewInstance() - { - return newInstance(AnimateWindow); - } - - void setAnimData( ICoord2D startPos, ICoord2D endPos, Coord2D curPos, ICoord2D restPos, Coord2D vel, UnsignedInt startTime, UnsignedInt endTime); - - ICoord2D getStartPos(); ///< Get the Start Position 2D coord - Coord2D getCurPos(); ///< Get the Current Position 2D coord - ICoord2D getEndPos(); ///< Get the End Position 2D coord - ICoord2D getRestPos(); ///< Get the Rest Position 2D coord - GameWindow *getGameWindow(); ///< Get the GameWindow that will be animating - AnimTypes getAnimType(); ///< Get the Animation type - UnsignedInt getDelay(); ///< Get the Time Delay - Coord2D getVel(); ///< Get the Velocity Position 2D coord - UnsignedInt getStartTime(); ///< Get the start time of the time-based anim - UnsignedInt getEndTime(); ///< Get the end time of the time-based anim - - void setStartPos( ICoord2D starPos); ///< Set the Start Position 2D coord - void setCurPos( Coord2D curPos); ///< Set the Current Position 2D coord - void setEndPos( ICoord2D endPos); ///< Set the End Position 2D coord - void setRestPos( ICoord2D restPos); ///< Set the Rest Position 2D coord - void setGameWindow( GameWindow *win); ///< Set the GameWindow that will be animating - void setAnimType( AnimTypes animType); ///< Set the Animation type - void setDelay( UnsignedInt delay); ///< Set the Time Delay - void setVel( Coord2D vel); ///< Set the Velocity Position 2D coord - void setStartTime( UnsignedInt t); ///< Set the start time of the time-based anim - void setEndTime( UnsignedInt t); ///< Set the end time of the time-based anim - - void setFinished(Bool finished); ///< Set if the animation has finished - Bool isFinished(); ///< Return if the animation has finished or not. - void setNeedsToFinish( Bool needsToFinish); ///< set if we need this animation to finish for the manager to return true - Bool needsToFinish(); ///< set if the animation has finished - -private: - UnsignedInt m_delay; ///< Holds the delay time in which the animation will start (in milliseconds) - ICoord2D m_startPos; ///< Holds the starting position of the animation - ///<(usually is also the end position of the animation when the animation is reversed) - ICoord2D m_endPos; ///< Holds the target End Position (usually is the same as the rest position) - Coord2D m_curPos; ///< It's Current Position - ICoord2D m_restPos; ///< When the Manager Resets, It sets the window's position to this position - GameWindow *m_win; ///< the window that this animation is happening on - Coord2D m_vel; ///< the Velocity of the animation - UnsignedInt m_startTime; ///< time we started the time-based anim - UnsignedInt m_endTime; ///< time we should end the time-based anim - AnimTypes m_animType; ///< The type of animation that will happen - Bool m_needsToFinish; ///< Flag to tell the manager if we need to finish before it's done with it's animation - Bool m_isFinished; ///< We're finished -}; -} // namespace wnd - - - -//----------------------------------------------------------------------------- -typedef std::list AnimateWindowList; - -//----------------------------------------------------------------------------- -class AnimateWindowManager : public SubsystemInterface -{ -public: - AnimateWindowManager(); - virtual ~AnimateWindowManager() override; - - // Inhertited from subsystem ==================================================================== - virtual void init() override; - virtual void reset() override; - virtual void update() override; - //=============================================================================================== - - void registerGameWindow(GameWindow *win, AnimTypes animType, Bool needsToFinish, UnsignedInt ms = 0, UnsignedInt delayMs = 0); // Registers a new window to animate. - Bool isFinished(); ///< Are all the animations that need to be finished, finished? - void reverseAnimateWindow(); ///< tell each animation type to setup the windows to run in reverse - void resetToRestPosition(); ///< Reset all windows to their rest position - Bool isReversed(); ///< Returns whether or not we're in our reversed state. - Bool isEmpty(); -private: - AnimateWindowList m_winList; ///< A list of AnimationWindows that we don't care if their finished animating - AnimateWindowList m_winMustFinishList; ///< A list of AnimationWindows that we do care about - Bool m_needsUpdate; ///< If we're done animating all our monitored windows, then this will be false - Bool m_reverse; ///< Are we in a reverse state? - ProcessAnimateWindowSlideFromRight *m_slideFromRight; ///< Holds the process in which the windows slide from the right - ProcessAnimateWindowSlideFromRightFast *m_slideFromRightFast; - ProcessAnimateWindowSlideFromTop *m_slideFromTop; ///< Holds the process in which the windows slide from the Top - ProcessAnimateWindowSlideFromLeft *m_slideFromLeft; ///< Holds the process in which the windows slide from the Left - ProcessAnimateWindowSlideFromBottom *m_slideFromBottom; ///< Holds the process in which the windows slide from the Bottom - ProcessAnimateWindowSpiral *m_spiral; ///< Holds the process in which the windows Spiral onto the screen - ProcessAnimateWindowSlideFromBottomTimed *m_slideFromBottomTimed; ///< Holds the process in which the windows slide from the Bottom in a time-based fashion - ProcessAnimateWindowSlideFromTopFast *m_slideFromTopFast; ///< holds the process in wich the windows slide from the top,fast - ProcessAnimateWindow *getProcessAnimate( AnimTypes animType); ///< returns the process for the kind of animation we need. - -}; - -//----------------------------------------------------------------------------- -// INLINING /////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -namespace wnd -{ - inline ICoord2D AnimateWindow::getStartPos() { return m_startPos; }; - inline Coord2D AnimateWindow::getCurPos() { return m_curPos; }; - inline ICoord2D AnimateWindow::getEndPos() { return m_endPos; }; - inline ICoord2D AnimateWindow::getRestPos() { return m_restPos; }; - inline GameWindow *AnimateWindow::getGameWindow(){ return m_win; }; - inline AnimTypes AnimateWindow::getAnimType() { return m_animType; }; - inline UnsignedInt AnimateWindow::getDelay() { return m_delay; }; - inline Coord2D AnimateWindow::getVel() { return m_vel; }; - inline UnsignedInt AnimateWindow::getStartTime() { return m_startTime; }; - inline UnsignedInt AnimateWindow::getEndTime() { return m_endTime; }; - - inline void AnimateWindow::setStartPos( ICoord2D startPos) { m_startPos = startPos; }; - inline void AnimateWindow::setCurPos( Coord2D curPos) { m_curPos = curPos; }; - inline void AnimateWindow::setEndPos( ICoord2D endPos) { m_endPos = endPos; }; - inline void AnimateWindow::setRestPos( ICoord2D restPos) { m_restPos = restPos; }; - inline void AnimateWindow::setGameWindow( GameWindow *win) { m_win = win; }; - inline void AnimateWindow::setAnimType( AnimTypes animType) { m_animType = animType; }; - inline void AnimateWindow::setDelay( UnsignedInt delay) { m_delay = delay; }; - inline void AnimateWindow::setVel( Coord2D vel) { m_vel = vel; }; - inline void AnimateWindow::setStartTime( UnsignedInt t ) { m_startTime = t; } - inline void AnimateWindow::setEndTime( UnsignedInt t ) { m_endTime = t; } - - inline void AnimateWindow::setFinished( Bool finished) { m_isFinished = finished; }; - inline Bool AnimateWindow::isFinished() { return m_isFinished; }; - inline void AnimateWindow::setNeedsToFinish( Bool needsToFinish) { m_needsToFinish = needsToFinish; }; - inline Bool AnimateWindow::needsToFinish() { return m_needsToFinish; }; -} // namespace wnd - - inline Bool AnimateWindowManager::isFinished() { return !m_needsUpdate; }; - inline Bool AnimateWindowManager::isReversed() { return m_reverse; }; - inline Bool AnimateWindowManager::isEmpty(){return (m_winList.empty() && m_winMustFinishList.empty()); } -//----------------------------------------------------------------------------- -// EXTERNALS ////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- diff --git a/Generals/Code/GameEngine/Include/GameClient/GameWindowID.h b/Generals/Code/GameEngine/Include/GameClient/GameWindowID.h deleted file mode 100644 index 9d5eec2be54..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/GameWindowID.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** 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 3 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, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: GameWindowID.h /////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: GameWindowID.h -// -// Created: Colin Day, July 2001 -// -// Desc: Game window ID definitions, this is so we can uniquely -// identify any window in the game and pass messages from -// anywhere to anywhere else instantly -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// - -// USER INCLUDES ////////////////////////////////////////////////////////////// - -// FORWARD REFERENCES ///////////////////////////////////////////////////////// - -// TYPE DEFINES /////////////////////////////////////////////////////////////// -#define GWID_INVALID 0 - -#define GWID_SIDEBAR 100 - -#define GWID_SIDEBAR_1 101 -#define GWID_SIDEBAR_2 102 -#define GWID_SIDEBAR_3 103 -#define GWID_SIDEBAR_4 104 -#define GWID_SIDEBAR_5 105 -#define GWID_SIDEBAR_6 106 -#define GWID_SIDEBAR_7 107 -#define GWID_SIDEBAR_8 108 -#define GWID_SIDEBAR_9 109 -#define GWID_SIDEBAR_10 110 -#define GWID_SIDEBAR_11 111 -#define GWID_SIDEBAR_12 112 - -#define GWID_SIDEBAR_TAB_1 151 -#define GWID_SIDEBAR_TAB_2 152 -#define GWID_SIDEBAR_TAB_3 153 -#define GWID_SIDEBAR_TAB_4 154 - -#define GWID_SIDEBAR_RADAR 175 - -// INLINING /////////////////////////////////////////////////////////////////// - -// EXTERNALS ////////////////////////////////////////////////////////////////// diff --git a/Generals/Code/GameEngine/Include/GameClient/GameWindowManager.h b/Generals/Code/GameEngine/Include/GameClient/GameWindowManager.h deleted file mode 100644 index a3a4f53a4a6..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/GameWindowManager.h +++ /dev/null @@ -1,414 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** 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 3 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, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: GameWindowManager.h ////////////////////////////////////////////////////////////////////// -// Created: Colin Day, June 2001 -// Desc: The game window manager is the interface for interacting with -// the windowing system for purposes of any menus, or GUI -// controls. -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "Common/STLTypedefs.h" -#include "Common/SubsystemInterface.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/Gadget.h" - -class GameWindow; - -//------------------------------------------------------------------------------------------------- -/** Window layout info is a structure that can be passed to the load function of - * a window script. After the script is loaded, this parameter (if present) - * will contain information about the script file at a global level such - * as what file version was loaded, global layout callbacks, etc */ -//------------------------------------------------------------------------------------------------- -enum { MAX_LAYOUT_FUNC_LEN = 256 }; - -typedef std::list GameWindowList; - -class WindowLayoutInfo -{ - -public: - WindowLayoutInfo(); - - UnsignedInt version; ///< file version that was loaded - WindowLayoutInitFunc init; ///< init method (if specified) - WindowLayoutUpdateFunc update; ///< update method (if specified) - WindowLayoutShutdownFunc shutdown; ///< shutdown method (if specified) - AsciiString initNameString; ///< init method in flavor of string name - AsciiString updateNameString; ///< update method in string flavor - AsciiString shutdownNameString; ///< shutdown method in string flavor, mmm! - std::list windows; ///< list of top-level windows in the layout -}; - -//------------------------------------------------------------------------------------------------- -/** There exists a singleton GameWindowManager that defines how we can - * interact with the game windowing system */ -//------------------------------------------------------------------------------------------------- -class GameWindowManager : public SubsystemInterface -{ - -friend class GameWindow; - -public: - - GameWindowManager(); - virtual ~GameWindowManager() override; - - //----------------------------------------------------------------------------------------------- - virtual void init() override; ///< initialize function - virtual void reset() override; ///< reset the system - virtual void update() override; ///< update method, called once per frame - - virtual GameWindow *allocateNewWindow() = 0; ///< new game window - - void linkWindow( GameWindow *window ); ///< link into master list - void unlinkWindow( GameWindow *window ); ///< unlink from master list - void unlinkChildWindow( GameWindow *window ); ///< remove child from parent list - void insertWindowAheadOf( GameWindow *window, GameWindow *aheadOf ); ///< add window to list 'ahead of' - - virtual GameWinDrawFunc getPushButtonImageDrawFunc() = 0; - virtual GameWinDrawFunc getPushButtonDrawFunc() = 0; - virtual GameWinDrawFunc getCheckBoxImageDrawFunc() = 0; - virtual GameWinDrawFunc getCheckBoxDrawFunc() = 0; - virtual GameWinDrawFunc getRadioButtonImageDrawFunc() = 0; - virtual GameWinDrawFunc getRadioButtonDrawFunc() = 0; - virtual GameWinDrawFunc getTabControlImageDrawFunc() = 0; - virtual GameWinDrawFunc getTabControlDrawFunc() = 0; - virtual GameWinDrawFunc getListBoxImageDrawFunc() = 0; - virtual GameWinDrawFunc getListBoxDrawFunc() = 0; - virtual GameWinDrawFunc getComboBoxImageDrawFunc() = 0; - virtual GameWinDrawFunc getComboBoxDrawFunc() = 0; - virtual GameWinDrawFunc getHorizontalSliderImageDrawFunc() = 0; - virtual GameWinDrawFunc getHorizontalSliderDrawFunc() = 0; - virtual GameWinDrawFunc getVerticalSliderImageDrawFunc() = 0; - virtual GameWinDrawFunc getVerticalSliderDrawFunc() = 0; - virtual GameWinDrawFunc getProgressBarImageDrawFunc() = 0; - virtual GameWinDrawFunc getProgressBarDrawFunc() = 0; - virtual GameWinDrawFunc getStaticTextImageDrawFunc() = 0; - virtual GameWinDrawFunc getStaticTextDrawFunc() = 0; - virtual GameWinDrawFunc getTextEntryImageDrawFunc() = 0; - virtual GameWinDrawFunc getTextEntryDrawFunc() = 0; - - //--------------------------------------------------------------------------- - - virtual GameWinDrawFunc getDefaultDraw(); ///< return default draw func - virtual GameWinSystemFunc getDefaultSystem(); ///< return default system func - virtual GameWinInputFunc getDefaultInput(); ///< return default input func - virtual GameWinTooltipFunc getDefaultTooltip(); ///< return default tooltip func - - //--------------------------------------------------------------------------- - // MessageBox creation - virtual GameWindow *gogoMessageBox(Int x, Int y, Int width, Int height, UnsignedShort buttonFlags, - UnicodeString titleString, UnicodeString bodyString, - GameWinMsgBoxFunc yesCallback, - GameWinMsgBoxFunc noCallback, - GameWinMsgBoxFunc okCallback, - GameWinMsgBoxFunc cancelCallback ); - - virtual GameWindow *gogoMessageBox(Int x, Int y, Int width, Int height, UnsignedShort buttonFlags, - UnicodeString titleString, UnicodeString bodyString, - GameWinMsgBoxFunc yesCallback, - GameWinMsgBoxFunc noCallback, - GameWinMsgBoxFunc okCallback, - GameWinMsgBoxFunc cancelCallback, Bool useLogo ); - - - //--------------------------------------------------------------------------- - // gadget creation - virtual GameWindow *gogoGadgetPushButton( GameWindow *parent, UnsignedInt status, - Int x, Int y, Int width, Int height, - WinInstanceData *instData, - GameFont *defaultFont, Bool defaultVisual ); - virtual GameWindow *gogoGadgetCheckbox( GameWindow *parent, UnsignedInt status, - Int x, Int y, Int width, Int height, - WinInstanceData *instData, - GameFont *defaultFont, Bool defaultVisual ); - virtual GameWindow *gogoGadgetRadioButton( GameWindow *parent, UnsignedInt status, - Int x, Int y, Int width, Int height, - WinInstanceData *instData, - RadioButtonData *rData, - GameFont *defaultFont, Bool defaultVisual ); - virtual GameWindow *gogoGadgetTabControl( GameWindow *parent, UnsignedInt status, - Int x, Int y, Int width, Int height, - WinInstanceData *instData, - TabControlData *rData, - GameFont *defaultFont, Bool defaultVisual ); - virtual GameWindow *gogoGadgetListBox( GameWindow *parent, UnsignedInt status, - Int x, Int y, Int width, Int height, - WinInstanceData *instData, - ListboxData *listboxData, - GameFont *defaultFont, Bool defaultVisual ); - virtual GameWindow *gogoGadgetSlider( GameWindow *parent, UnsignedInt status, - Int x, Int y, Int width, Int height, - WinInstanceData *instData, - SliderData *sliderData, - GameFont *defaultFont, Bool defaultVisual ); - virtual GameWindow *gogoGadgetProgressBar( GameWindow *parent, UnsignedInt status, - Int x, Int y, Int width, Int height, - WinInstanceData *instData, - GameFont *defaultFont, Bool defaultVisual ); - virtual GameWindow *gogoGadgetStaticText( GameWindow *parent, UnsignedInt status, - Int x, Int y, Int width, Int height, - WinInstanceData *instData, - TextData *textData, - GameFont *defaultFont, Bool defaultVisual ); - virtual GameWindow *gogoGadgetTextEntry( GameWindow *parent, UnsignedInt status, - Int x, Int y, Int width, Int height, - WinInstanceData *instData, - EntryData *entryData, - GameFont *defaultFont, Bool defaultVisual ); - virtual GameWindow *gogoGadgetComboBox( GameWindow *parent, UnsignedInt status, - Int x, Int y, Int width, Int height, - WinInstanceData *instData, - ComboBoxData *comboBoxDataTemplate, - GameFont *defaultFont, Bool defaultVisual ); - - /** Use this method to assign the default images to gadgets as - * they area created */ - virtual void assignDefaultGadgetLook( GameWindow *gadget, - GameFont *defaultFont, - Bool assignVisual ); - - //--------------------------------------------------------------------------- - // Creating windows - /// create new window(s) from .wnd file ... see definition for what is returned - virtual GameWindow *winCreateFromScript( AsciiString filename, WindowLayoutInfo *info = nullptr ); - - /// create new window(s) from .wnd file and wrap in a WindowLayout - virtual WindowLayout *winCreateLayout( AsciiString filename ); - - /// free temporary strings to make the memory leak manager happy. - virtual void freeStaticStrings(); - - /// create a new window by setting up parameters and callbacks - virtual GameWindow *winCreate( GameWindow *parent, UnsignedInt status, - Int x, Int y, Int width, Int height, - GameWinSystemFunc system, - WinInstanceData *instData = nullptr ); - - //--------------------------------------------------------------------------- - // Manipulating windows in the system - virtual Int winDestroy( GameWindow *window ); ///< destroy this window - virtual Int winDestroyAll(); ///< destroy all windows in the system - virtual GameWindow *winGetWindowList(); ///< get head of master list - - /// hide all windows in a certain range of id's (inclusive ); - virtual void hideWindowsInRange( GameWindow *baseWindow, Int first, Int last, - Bool hideFlag ); - /// enable all windows in a range of id's (inclusive) - virtual void enableWindowsInRange( GameWindow *baseWindow, Int first, Int last, - Bool enableFlag ); - - /// this gets called from winHide() when a window hides itself - virtual void windowHiding( GameWindow *window ); - - virtual void winRepaint(); ///< draw GUI in reverse order - - virtual void winNextTab( GameWindow *window ); ///< give keyboard focus to the next window in the tab list - - virtual void winPrevTab( GameWindow *window ); ///< give keyboard focus to the previous window in the tab list - - virtual void registerTabList( GameWindowList tabList ); ///< we have to register a Tab List - virtual void clearTabList(); ///< we's gotz ta clear the tab list yo! - - // -------------------------------------------------------------------------- - /// process a single mouse event - virtual WinInputReturnCode winProcessMouseEvent( GameWindowMessage msg, - ICoord2D *mousePos, - void *data ); - /// process a singke key event - virtual WinInputReturnCode winProcessKey( UnsignedByte key, - UnsignedByte state ); - // -------------------------------------------------------------------------- - - virtual GameWindow *winGetFocus(); ///< return window that has the focus - virtual Int winSetFocus( GameWindow *window ); ///< set this window as has focus - virtual void winSetGrabWindow( GameWindow *window ); ///< set the grab window - virtual GameWindow *winGetGrabWindow(); ///< who is currently 'held' by mouse - virtual void winSetLoneWindow( GameWindow *window ); ///< set the open window - - // Finds the top-level window at the mouse position that matches the required and forbidden status masks. - virtual GameWindow* findWindowUnderMouse(GameWindow*& toolTipWindow, const ICoord2D* mousePos, unsigned int requiredStatusMask, unsigned int forbiddenStatusMask); - static bool isMouseWithinWindow(GameWindow* window, const ICoord2D* mousePos, unsigned int requiredStatusMask, unsigned int forbiddenStatusMask); - - virtual Bool isEnabled( GameWindow *win ); ///< is window or parents enabled - virtual Bool isHidden( GameWindow *win ); ///< is parent or parents hidden - virtual void addWindowToParent( GameWindow *window, GameWindow *parent ); - virtual void addWindowToParentAtEnd( GameWindow *window, GameWindow *parent ); - - /// sends a system message to specified window - virtual WindowMsgHandledType winSendSystemMsg( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ); - - /// sends an input message to the specified window - virtual WindowMsgHandledType winSendInputMsg( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ); - - /** get the window pointer from id, starting at 'window' and searching - down the hierarchy. If 'window' is nullptr then all windows will - be searched */ - virtual GameWindow *winGetWindowFromId( GameWindow *window, Int id ); - virtual Int winCapture( GameWindow *window ); ///< captures the mouse - virtual Int winRelease( GameWindow *window ); ///< release mouse capture - virtual GameWindow *winGetCapture(); ///< current mouse capture settings - - virtual Int winSetModal( GameWindow *window ); ///< put at top of modal stack - virtual Int winUnsetModal( GameWindow *window ); /**< take window off modal stack, if window is - not at top of stack and error will occur */ - - //--------------------------------------------------------------------------- - ///////////////////////////////////////////////////////////////////////////// - //--------------------------------------------------------------------------- - //--------------------------------------------------------------------------- - // The following public functions you should implement change the guts - // for to work with your application. Rather than draw images, or do string - // operations with native methods, the game window system will always call - // these methods to get the work done it needs - //--------------------------------------------------------------------------- - //--------------------------------------------------------------------------- - ///////////////////////////////////////////////////////////////////////////// - //--------------------------------------------------------------------------- - - /// draw image, coord are in screen and should be kepth within that box specified - virtual void winDrawImage( const Image *image, Int startX, Int startY, Int endX, Int endY, Color color = 0xFFFFFFFF ); - /// draw filled rect, coords are absolute screen coords - virtual void winFillRect( Color color, Real width, Int startX, Int startY, Int endX, Int endY ); - /// draw rect outline, coords are absolute screen coords - virtual void winOpenRect( Color color, Real width, Int startX, Int startY, Int endX, Int endY ); - /// draw line, coords are absolute screen coords - virtual void winDrawLine( Color color, Real width, Int startX, Int startY, Int endX, Int endY ); - /// Make a color representation out of RGBA components - virtual Color winMakeColor( UnsignedByte red, UnsignedByte green, UnsignedByte blue, UnsignedByte alpha ); - /** Find an image reference and return a pointer to its image, you may - recreate all Image structs to suit your project */ - virtual const Image *winFindImage( const char *name ); - virtual Int winFontHeight( GameFont *font ); ///< get height of font in pixels - virtual Int winIsDigit( Int c ); ///< is character a digit - virtual Int winIsAscii( Int c ); ///< is character a digit - virtual Int winIsAlNum( Int c ); ///< is character alpha-numeric - virtual void winFormatText( GameFont *font, UnicodeString text, Color color, - Int x, Int y, Int width, Int height ); - virtual void winGetTextSize( GameFont *font, UnicodeString text, - Int *width, Int *height, Int maxWidth ); - virtual UnicodeString winTextLabelToText( AsciiString label ); ///< convert localizable text label to real text - virtual GameFont *winFindFont( AsciiString fontName, Int pointSize, Bool bold ); ///< get a font given a name - - /// @todo just for testing, remov this - Bool initTestGUI(); - - virtual GameWindow *getWindowUnderCursor( Int x, Int y, Bool ignoreEnabled = FALSE ); ///< find the top window at the given coordinates - - //--------------------------------------------------------------------------- - ///////////////////////////////////////////////////////////////////////////// - //--------------------------------------------------------------------------- - //--------------------------------------------------------------------------- - //--------------------------------------------------------------------------- - //--------------------------------------------------------------------------- - ///////////////////////////////////////////////////////////////////////////// - //--------------------------------------------------------------------------- - -protected: - - void processDestroyList(); ///< process windows waiting to be killed - - Int drawWindow( GameWindow *window ); ///< draw this window - - void dumpWindow( GameWindow *window ); ///< for debugging - - GameWindow *m_windowList; // list of all top level windows - GameWindow *m_windowTail; // last in windowList - - GameWindow *m_destroyList; // list of windows to destroy - - GameWindow *m_currMouseRgn; // window that mouse is over - GameWindow *m_mouseCaptor; // window that captured mouse - GameWindow *m_keyboardFocus; // window that has input focus - ModalWindow *m_modalHead; // top of windows in the modal stack - GameWindow *m_grabWindow; // window that grabbed the last down event - GameWindow *m_loneWindow; // Set if we just opened a Lone Window - GameWindowList m_tabList; // we have to register a tab list to make a tab list. - const Image *m_cursorBitmap; - UnsignedInt m_captureFlags; - -}; - -// INLINE ///////////////////////////////////////////////////////////////////////////////////////// -inline GameWinDrawFunc GameWindowManager::getDefaultDraw() { return GameWinDefaultDraw; } -inline GameWinSystemFunc GameWindowManager::getDefaultSystem() { return GameWinDefaultSystem; } -inline GameWinInputFunc GameWindowManager::getDefaultInput() { return GameWinDefaultInput; } -inline GameWinTooltipFunc GameWindowManager::getDefaultTooltip() { return GameWinDefaultTooltip; } - -// EXTERN ///////////////////////////////////////////////////////////////////////////////////////// -extern GameWindowManager *TheWindowManager; ///< singleton extern definition -extern UnsignedInt WindowLayoutCurrentVersion; ///< current version of our window layouts - -// this function lets us generically pass button selections to our parent, we may -// frequently want to do this because we want windows grouped on child windows for -// convenience, but only want one logical system procedure responding to them all -extern WindowMsgHandledType PassSelectedButtonsToParentSystem( GameWindow *window, - UnsignedInt msg, - WindowMsgData mData1, - WindowMsgData mData2 ); -extern WindowMsgHandledType PassMessagesToParentSystem( GameWindow *window, - UnsignedInt msg, - WindowMsgData mData1, - WindowMsgData mData2 ); - -// TheSuperHackers @feature helmutbuhler 24/04/2025 -// GameWindowManager that does nothing. Used for Headless Mode. -class GameWindowManagerDummy : public GameWindowManager -{ -public: - virtual GameWindow *winGetWindowFromId(GameWindow *window, Int id) override; - virtual GameWindow *winCreateFromScript(AsciiString filenameString, WindowLayoutInfo *info) override; - - virtual GameWindow *allocateNewWindow() override { return newInstance(GameWindowDummy); } - - virtual GameWinDrawFunc getPushButtonImageDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getPushButtonDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getCheckBoxImageDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getCheckBoxDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getRadioButtonImageDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getRadioButtonDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getTabControlImageDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getTabControlDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getListBoxImageDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getListBoxDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getComboBoxImageDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getComboBoxDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getHorizontalSliderImageDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getHorizontalSliderDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getVerticalSliderImageDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getVerticalSliderDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getProgressBarImageDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getProgressBarDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getStaticTextImageDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getStaticTextDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getTextEntryImageDrawFunc() override { return nullptr; } - virtual GameWinDrawFunc getTextEntryDrawFunc() override { return nullptr; } -}; diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp deleted file mode 100644 index 2dd828857d1..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp +++ /dev/null @@ -1,426 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** 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 3 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, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: AnimateWindowManager.cpp ///////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Electronic Arts Pacific. -// -// Confidential Information -// Copyright (C) 2002 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// created: Mar 2002 -// -// Filename: AnimateWindowManager.cpp -// -// author: Chris Huybregts -// -// purpose: This will contain the logic behind the different animations that -// can happen to a window. -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -//----------------------------------------------------------------------------- -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// USER INCLUDES ////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "GameClient/AnimateWindowManager.h" -#include "GameClient/GameWindow.h" -#include "GameClient/Display.h" -#include "GameClient/ProcessAnimateWindow.h" -#include "Common/FramePacer.h" -//----------------------------------------------------------------------------- -// DEFINES //////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// AnimateWindow PUBLIC FUNCTIONS ///////////////////////////////////////////// -//----------------------------------------------------------------------------- -namespace wnd -{ -AnimateWindow::AnimateWindow() -{ - m_delay = 0; - m_startPos.x = m_startPos.y = 0; - m_endPos.x = m_endPos.y = 0; - m_curPos.x = m_curPos.y = 0.0f; - m_win = nullptr; - m_animType = WIN_ANIMATION_NONE; - - m_restPos.x = m_restPos.y = 0; - m_vel.x = m_vel.y = 0.0f; - m_needsToFinish = FALSE; - m_isFinished = FALSE; - m_endTime = 0; - m_startTime = 0; -} -AnimateWindow::~AnimateWindow() -{ - m_win = nullptr; -} - -void AnimateWindow::setAnimData( ICoord2D startPos, ICoord2D endPos, - Coord2D curPos, ICoord2D restPos, - Coord2D vel, UnsignedInt startTime, - UnsignedInt endTime ) - -{ - m_startPos = startPos; - m_endPos = endPos; - m_curPos = curPos; - m_restPos = restPos; - m_vel = vel; - m_startTime = startTime; - m_endTime = endTime; - -} - -} // namespace wnd - -//----------------------------------------------------------------------------- -// PUBLIC FUNCTIONS /////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -static void clearWinList(AnimateWindowList &winList) -{ - while (!winList.empty()) - { - wnd::AnimateWindow *win = *(winList.begin()); - winList.pop_front(); - deleteInstance(win); - } -} - -AnimateWindowManager::AnimateWindowManager() -{ -// we don't allocate many of these, so no MemoryPools used - m_slideFromRight = NEW ProcessAnimateWindowSlideFromRight; - m_slideFromRightFast = NEW ProcessAnimateWindowSlideFromRightFast; - m_slideFromLeft = NEW ProcessAnimateWindowSlideFromLeft; - m_slideFromTop = NEW ProcessAnimateWindowSlideFromTop; - m_slideFromTopFast = NEW ProcessAnimateWindowSlideFromTopFast; - m_slideFromBottom = NEW ProcessAnimateWindowSlideFromBottom; - m_spiral = NEW ProcessAnimateWindowSpiral; - m_slideFromBottomTimed = NEW ProcessAnimateWindowSlideFromBottomTimed; - m_winList.clear(); - m_needsUpdate = FALSE; - m_reverse = FALSE; - m_winMustFinishList.clear(); -} -AnimateWindowManager::~AnimateWindowManager() -{ - delete m_slideFromRight; - delete m_slideFromRightFast; - delete m_slideFromLeft; - delete m_slideFromTop; - delete m_slideFromTopFast; - delete m_slideFromBottom; - delete m_spiral; - delete m_slideFromBottomTimed; - - m_slideFromRight = nullptr; - resetToRestPosition(); - clearWinList(m_winList); - clearWinList(m_winMustFinishList); -} - - -void AnimateWindowManager::init() -{ - clearWinList(m_winList); - clearWinList(m_winMustFinishList); - m_needsUpdate = FALSE; - m_reverse = FALSE; -} - -void AnimateWindowManager::reset() -{ - resetToRestPosition(); - clearWinList(m_winList); - clearWinList(m_winMustFinishList); - m_needsUpdate = FALSE; - m_reverse = FALSE; -} - -// TheSuperHackers @tweak bobtista 04/08/2026 Advances the animations by a fractional base rate frame -// so that they move fluently on high render frame rates. -void AnimateWindowManager::update() -{ - const Real deltaFrames = TheFramePacer->getBaseOverUpdateFpsRatio(); - - ProcessAnimateWindow *processAnim = nullptr; - - // if we need to update the windows that need to finish, update that list - if(m_needsUpdate) - { - AnimateWindowList::iterator it = m_winMustFinishList.begin(); - m_needsUpdate = FALSE; - - while (it != m_winMustFinishList.end()) - { - wnd::AnimateWindow *animWin = *it; - if (!animWin) - { - DEBUG_CRASH(("There's No AnimateWindow in the AnimateWindow List")); - return; - } - processAnim = getProcessAnimate( animWin->getAnimType() ); - if(processAnim) - { - if(m_reverse) - { - if(!processAnim->reverseAnimateWindow(animWin, deltaFrames)) - m_needsUpdate = TRUE; - } - else - { - if(!processAnim->updateAnimateWindow(animWin, deltaFrames)) - m_needsUpdate = TRUE; - } - } - - it ++; - } - } - - AnimateWindowList::iterator it = m_winList.begin(); - - while (it != m_winList.end()) - { - wnd::AnimateWindow *animWin = *it; - if (!animWin) - { - DEBUG_CRASH(("There's No AnimateWindow in the AnimateWindow List")); - return; - } - processAnim = getProcessAnimate( animWin->getAnimType() ); - if(m_reverse) - { - if(processAnim) - processAnim->reverseAnimateWindow(animWin, deltaFrames); - } - else - { - if(processAnim) - processAnim->updateAnimateWindow(animWin, deltaFrames); - } - it ++; - } -} - - -void AnimateWindowManager::registerGameWindow(GameWindow *win, AnimTypes animType, Bool needsToFinish, UnsignedInt ms, UnsignedInt delayMs) -{ - if(!win) - { - DEBUG_CRASH(("Win was null as it was passed into registerGameWindow... not good indeed")); - return; - } - if(animType <= WIN_ANIMATION_NONE || animType >= WIN_ANIMATION_COUNT ) - { - DEBUG_CRASH(("an Invalid WIN_ANIMATION type was passed into registerGameWindow... please fix me ")); - return; - } - - // Create a new AnimateWindow class and fill in it's data. - wnd::AnimateWindow *animWin = wnd::AnimateWindow::createNewInstance(); - animWin->setGameWindow(win); - animWin->setAnimType(animType); - animWin->setNeedsToFinish(needsToFinish); - animWin->setDelay(delayMs); - - // Run the window through the processAnim's init function. - ProcessAnimateWindow *processAnim = getProcessAnimate( animType ); - if(processAnim) - { - processAnim->setMaxDuration(ms); - processAnim->initAnimateWindow( animWin ); - } - - // Add the Window to the proper list - if(needsToFinish) - { - m_winMustFinishList.push_back(animWin); - m_needsUpdate = TRUE; - } - else - m_winList.push_back(animWin); -} - -ProcessAnimateWindow *AnimateWindowManager::getProcessAnimate( AnimTypes animType ) -{ - switch (animType) { - case WIN_ANIMATION_SLIDE_RIGHT: - { - return m_slideFromRight; - } - case WIN_ANIMATION_SLIDE_RIGHT_FAST: - { - return m_slideFromRightFast; - } - case WIN_ANIMATION_SLIDE_LEFT: - { - return m_slideFromLeft; - } - case WIN_ANIMATION_SLIDE_TOP: - { - return m_slideFromTop; - } - case WIN_ANIMATION_SLIDE_BOTTOM: - { - return m_slideFromBottom; - } - case WIN_ANIMATION_SPIRAL: - { - return m_spiral; - } - case WIN_ANIMATION_SLIDE_BOTTOM_TIMED: - { - return m_slideFromBottomTimed; - } - case WIN_ANIMATION_SLIDE_TOP_FAST: - { - return m_slideFromTopFast; - } - default: - return nullptr; - } -} - -void AnimateWindowManager::reverseAnimateWindow() -{ - - m_reverse = TRUE; - m_needsUpdate = TRUE; - ProcessAnimateWindow *processAnim = nullptr; - - UnsignedInt maxDelay = 0; - AnimateWindowList::iterator it = m_winMustFinishList.begin(); - while (it != m_winMustFinishList.end()) - { - wnd::AnimateWindow *animWin = *it; - if (!animWin) - { - DEBUG_CRASH(("There's No AnimateWindow in the AnimateWindow List")); - return; - } - if(animWin->getDelay() > maxDelay) - maxDelay = animWin->getDelay(); - it ++; - } - - it = m_winMustFinishList.begin(); - while (it != m_winMustFinishList.end()) - { - wnd::AnimateWindow *animWin = *it; - if (!animWin) - { - DEBUG_CRASH(("There's No AnimateWindow in the AnimateWindow List")); - return; - } - // Run the window through the processAnim's init function. - processAnim = getProcessAnimate( animWin->getAnimType() ); - if(processAnim) - { - processAnim->initReverseAnimateWindow( animWin, maxDelay ); - } - - animWin->setFinished(FALSE); - it ++; - } - - it = m_winList.begin(); - - while (it != m_winList.end()) - { - wnd::AnimateWindow *animWin = *it; - if (!animWin) - { - DEBUG_CRASH(("There's No AnimateWindow in the AnimateWindow List")); - return; - } - processAnim = getProcessAnimate( animWin->getAnimType() ); - - if(processAnim) - processAnim->initReverseAnimateWindow(animWin); - animWin->setFinished(FALSE); - it ++; - } - -} - -void AnimateWindowManager::resetToRestPosition() -{ - - m_reverse = TRUE; - m_needsUpdate = TRUE; - - AnimateWindowList::iterator it = m_winMustFinishList.begin(); - while (it != m_winMustFinishList.end()) - { - wnd::AnimateWindow *animWin = *it; - if (!animWin) - { - DEBUG_CRASH(("There's No AnimateWindow in the AnimateWindow List")); - return; - } - ICoord2D restPos = animWin->getRestPos(); - GameWindow *win = animWin->getGameWindow(); - if(win) - win->winSetPosition(restPos.x, restPos.y); - it ++; - } - it = m_winList.begin(); - while (it != m_winList.end()) - { - wnd::AnimateWindow *animWin = *it; - if (!animWin) - { - DEBUG_CRASH(("There's No AnimateWindow in the AnimateWindow List")); - return; - } - ICoord2D restPos = animWin->getRestPos(); - GameWindow *win = animWin->getGameWindow(); - if(win) - win->winSetPosition(restPos.x, restPos.y); - it ++; - } - - -} - -//----------------------------------------------------------------------------- -// PRIVATE FUNCTIONS ////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - - - diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp deleted file mode 100644 index d3d2afadcdc..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp +++ /dev/null @@ -1,4064 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** 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 3 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, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: GameWindowManager.cpp //////////////////////////////////////////////////////////////////// -// Created: Colin Day, June 2001 -// Dean Iverson, March 1998 (Original window code) -// Desc: The game window manager is the singleton class that we interface -// with to interact with the game windowing system. -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "Common/Debug.h" -#include "Common/Language.h" -#include "GameClient/Display.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GameWindow.h" -#include "GameClient/Mouse.h" -#include "GameClient/DisplayStringManager.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/GameWindowGlobal.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetComboBox.h" -#include "GameClient/GadgetTabControl.h" -#include "GameClient/GadgetProgressBar.h" -#include "GameClient/GadgetStaticText.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameClient/GadgetSlider.h" -#include "GameClient/GadgetRadioButton.h" -#include "GameClient/GadgetCheckBox.h" -#include "GameClient/GlobalLanguage.h" -#include "GameClient/GameWindowTransitions.h" -#include "Common/NameKeyGenerator.h" - -// PUBLIC DATA //////////////////////////////////////////////////////////////////////////////////// -GameWindowManager *TheWindowManager = nullptr; -UnsignedInt WindowLayoutCurrentVersion = 2; - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// PRIVATE FUNCTIONS ////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -// -// with this status set to true, the window system will propagate mouse position -// messages to windows. You may want to disable this if you feel the mouse position -// messages are "spamming" your window and making a particular debugging situation -// difficult. Make sure you do enable this before you check in again tho because -// it is necessary for any code that needs to look at objects or anything under -// the radar cursor -// -static Bool sendMousePosMessages = TRUE; - -//------------------------------------------------------------------------------------------------- -/** Process windows waiting to be destroyed */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::processDestroyList() -{ - GameWindow *next; - GameWindow *doDestroy; - - // - // we need to pass the ownership of the destroy list so - // if, while destroying a window, we need to add other windows - // to the destroy list it won't cause problems. - // - doDestroy = m_destroyList; - - // set the list to empty - m_destroyList = nullptr; - - // do the destroys - for( ; doDestroy; doDestroy = next ) - { - - next = doDestroy->m_next; - - // Check to see if this window is "special" - if( m_mouseCaptor == doDestroy ) - winRelease( doDestroy ); - - if( m_keyboardFocus == doDestroy ) - winSetFocus( nullptr ); - - if( (m_modalHead != nullptr) && (doDestroy == m_modalHead->window) ) - winUnsetModal( m_modalHead->window ); - - if( m_currMouseRgn == doDestroy ) - m_currMouseRgn = nullptr; - - if( m_grabWindow == doDestroy ) - m_grabWindow = nullptr; - - // send the destroy message to the window we're about to kill - winSendSystemMsg( doDestroy, GWM_DESTROY, 0, 0 ); - - DEBUG_ASSERTCRASH(doDestroy->winGetUserData() == nullptr, ("Win user data is expected to be deleted now")); - - // free the memory - deleteInstance(doDestroy); - - } - -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// PUBLIC FUNCTIONS /////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------------------------------- -/** Generic function to simply propagate only button press messages to parent and let it deal with it */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType PassSelectedButtonsToParentSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - - // sanity - if( window == nullptr ) - return MSG_IGNORED; - - if( (msg == GBM_SELECTED) || (msg == GBM_SELECTED_RIGHT) || (msg == GBM_MOUSE_ENTERING) || (msg == GBM_MOUSE_LEAVING) || (msg == GEM_EDIT_DONE)) - { - GameWindow *parent = window->winGetParent(); - - if( parent ) - return TheWindowManager->winSendSystemMsg( parent, msg, mData1, mData2 ); - - } - - return MSG_IGNORED; - -} - -//------------------------------------------------------------------------------------------------- -/** Generic function to simply propagate only button press messages to parent and let it deal with it */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType PassMessagesToParentSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - - // sanity - if( window == nullptr ) - return MSG_IGNORED; - - - GameWindow *parent = window->winGetParent(); - - if( parent ) - return TheWindowManager->winSendSystemMsg( parent, msg, mData1, mData2 ); - - return MSG_IGNORED; - -} - - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -GameWindowManager::GameWindowManager() -{ - - m_windowList = nullptr; // list of all top level windows - m_windowTail = nullptr; // last in windowList - - m_destroyList = nullptr; // list of windows to destroy - - m_currMouseRgn = nullptr; // window that mouse is over - m_mouseCaptor = nullptr; // window that captured mouse - m_keyboardFocus = nullptr; // window that has input focus - m_modalHead = nullptr; // top of windows in the modal stack - m_grabWindow = nullptr; // window that grabbed the last down event - m_loneWindow = nullptr; // Set if we just opened a combo box - - m_cursorBitmap = nullptr; - m_captureFlags = 0; - -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -GameWindowManager::~GameWindowManager() -{ - - // destroy all windows - winDestroyAll(); - freeStaticStrings(); - - delete TheTransitionHandler; - TheTransitionHandler = nullptr; -} - -//------------------------------------------------------------------------------------------------- -/** Initialize the game window manager system */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::init() -{ - if(!TheTransitionHandler) - TheTransitionHandler = NEW GameWindowTransitionsHandler; - TheTransitionHandler->load(); - TheTransitionHandler->init(); -} - -//------------------------------------------------------------------------------------------------- -/** Reset window system */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::reset() -{ - - // destroy all windows left - winDestroyAll(); - if(TheTransitionHandler) - TheTransitionHandler->reset(); - -} - -//------------------------------------------------------------------------------------------------- -/** Update cycle for game window manager */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::update() -{ - - // Process windows waiting to be destroyed - processDestroyList(); - if(TheTransitionHandler) - TheTransitionHandler->update(); -} - -//------------------------------------------------------------------------------------------------- -/** Puts a window at the head of the window list */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::linkWindow( GameWindow *window ) -{ - GameWindow *lastModalWindow = nullptr; - GameWindow *tmp = m_windowList; - while (tmp) - { - const ModalWindow *modal = m_modalHead; - while (modal) - { - if (modal->window == tmp && modal->window != window) - { - lastModalWindow = tmp; - } - modal = modal->next; - } - tmp = tmp->m_next; - } - - if (!lastModalWindow) - { - - // Add to head of the top level window list - window->m_prev = nullptr; - window->m_next = m_windowList; - - if( m_windowList ) - m_windowList->m_prev = window; - else - { - // first on list is also the tail - m_windowTail = window; - } - - m_windowList = window; - } - else - { - // lastModalWindow points to a modal window - add behind it - window->m_prev = lastModalWindow; - window->m_next = lastModalWindow->m_next; - lastModalWindow->m_next = window; - if (window->m_next) - { - window->m_next->m_prev = window; - } - } - -} - -//------------------------------------------------------------------------------------------------- -/** Insert the window ahead of the the 'aheadOf' window. 'aheadOf' can - * be a window in the master list or a child of any window in that master - * list */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::insertWindowAheadOf( GameWindow *window, - GameWindow *aheadOf ) -{ - - // sanity - if( window == nullptr ) - return; - - // we'll say that an aheadOf window means at the head of the list - if( aheadOf == nullptr ) - { - - linkWindow( window ); - return; - - } - - // get parent of aheadOf - GameWindow *aheadOfParent = aheadOf->winGetParent(); - - // - // if ahead of has no parent insert it in the master list just before - // ahead of - // - if( aheadOfParent == nullptr ) - { - - window->m_prev = aheadOf->m_prev; - - if( aheadOf->m_prev ) - aheadOf->m_prev->m_next = window; - else - m_windowList = window; - - aheadOf->m_prev = window; - window->m_next = aheadOf; - - } - else - { - - window->m_prev = aheadOf->m_prev; - - if( aheadOf->m_prev ) - aheadOf->m_prev->m_next = window; - else - aheadOfParent->m_child = window; - - aheadOf->m_prev = window; - window->m_next = aheadOf; - - window->m_parent = aheadOfParent; - - } - -} - -//------------------------------------------------------------------------------------------------- -/** Takes a window off the window list */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::unlinkWindow( GameWindow *window ) -{ - - if( window->m_next ) - window->m_next->m_prev = window->m_prev; - else - { - // no next means this is the tail - m_windowTail = window->m_prev; - } - - if( window->m_prev ) - window->m_prev->m_next = window->m_next; - else - m_windowList = window->m_next; - -} - -//------------------------------------------------------------------------------------------------- -/** Takes a child window off its parent's window list */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::unlinkChildWindow( GameWindow *window ) -{ - - if( window->m_prev ) - { - - window->m_prev->m_next = window->m_next; - - if( window->m_next ) - window->m_next->m_prev = window->m_prev; - - } - else - { - - if( window->m_next ) - { - - window->m_parent->m_child = window->m_next; - - window->m_next->m_prev = window->m_prev; - - window->m_next = nullptr; - - } - else - { - - window->m_parent->m_child = nullptr; - - } - - } - - // remove the parent reference from this window - window->m_parent = nullptr; - -} - -//------------------------------------------------------------------------------------------------- -/** Check window and parents to see if this window is enabled */ -//------------------------------------------------------------------------------------------------- -Bool GameWindowManager::isEnabled( GameWindow *win ) -{ - - // sanity - if( win == nullptr ) - return FALSE; - - if( BitIsSet( win->m_status, WIN_STATUS_ENABLED ) == FALSE ) - { - return FALSE; - } - - while( win->m_parent ) - { - win = win->m_parent; - if( BitIsSet( win->m_status, WIN_STATUS_ENABLED ) == FALSE ) - { - return FALSE; - } - } - - return TRUE; - -} - -//------------------------------------------------------------------------------------------------- -/** Check window and parents to see if this window is hidden */ -//------------------------------------------------------------------------------------------------- -Bool GameWindowManager::isHidden( GameWindow *win ) -{ - - // we'll allow for the idea that if a window doesn't exist it is hidden - if( win == nullptr ) - return TRUE; - - if( BitIsSet( win->m_status, WIN_STATUS_HIDDEN )) - { - return TRUE; - } - - while( win->m_parent ) - { - win = win->m_parent; - if( BitIsSet( win->m_status, WIN_STATUS_HIDDEN )) - { - return TRUE; - } - } - - return FALSE; - -} - -//------------------------------------------------------------------------------------------------- -// Adds a child window to its parent. -//------------------------------------------------------------------------------------------------- -void GameWindowManager::addWindowToParent( GameWindow *window, - GameWindow *parent ) -{ - if( parent ) - { - - // add to parent's list of children - window->m_prev = nullptr; - window->m_next = parent->m_child; - - if( parent->m_child ) - parent->m_child->m_prev = window; - - parent->m_child = window; - - window->m_parent = parent; - - } - -} - -//------------------------------------------------------------------------------------------------- -/** Add a child window to the parent, put place it at the end of the - * parent window child list */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::addWindowToParentAtEnd( GameWindow *window, - GameWindow *parent ) -{ - - if( parent ) - { - - window->m_prev = nullptr; - window->m_next = nullptr; - if( parent->m_child ) - { - GameWindow *last; - - // wind down to last child in list - last = parent->m_child; - while( last->m_next != nullptr ) - last = last->m_next; - - // tie to list - last->m_next = window; - window->m_prev = last; - - } - else - parent->m_child = window; - - // assign the parent to the window - window->m_parent = parent; - - } - -} - -//------------------------------------------------------------------------------------------------- -/** this gets called from winHide() when a window hides itself */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::windowHiding( GameWindow *window ) -{ - - // if this window has keyboard focus remove it - if( m_keyboardFocus == window ) - m_keyboardFocus = nullptr; - - // if this is the modal head, unset it - if( m_modalHead && m_modalHead->window == window ) - winUnsetModal( window ); - - // if this is the captor, it shall no longer be - if( m_mouseCaptor == window ) - winCapture( nullptr ); - - // - // since hiding a parent will also hide the children, when a parent - // hides we must call this same method for all the children so they - // each have a chance to go through this logic - // - GameWindow *child; - for( child = window->winGetChild(); child; child = child->winGetNext() ) - windowHiding( child ); - -} - -//------------------------------------------------------------------------------------------------- -/** Hide all windows in a certain range of id's (inclusive) */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::hideWindowsInRange( GameWindow *baseWindow, - Int first, Int last, - Bool hideFlag ) -{ - Int i; - GameWindow *window; - - for( i = first; i <= last; i++ ) - { - - window = winGetWindowFromId( baseWindow, i ); - if( window ) - window->winHide( hideFlag ); - - } - -} - -//------------------------------------------------------------------------------------------------- -// Enable all windows in a certain range of id's (inclusive) -//------------------------------------------------------------------------------------------------- -void GameWindowManager::enableWindowsInRange( GameWindow *baseWindow, - Int first, Int last, - Bool enableFlag ) -{ - Int i; - GameWindow *window; - - for( i =first; i <= last; i++ ) - { - - window = winGetWindowFromId( baseWindow, i ); - if( window ) - window->winEnable( enableFlag ); - - } - -} - -//------------------------------------------------------------------------------------------------- -/** Captures the mouse capture. */ -//------------------------------------------------------------------------------------------------- -Int GameWindowManager::winCapture( GameWindow *window ) -{ - - if( m_mouseCaptor != nullptr) - return WIN_ERR_MOUSE_CAPTURED; - - m_mouseCaptor = window; - - return WIN_ERR_OK; - -} - -//------------------------------------------------------------------------------------------------- -/** Releases the mouse capture. */ -//------------------------------------------------------------------------------------------------- -Int GameWindowManager::winRelease( GameWindow *window ) -{ - - if( window == m_mouseCaptor ) - m_mouseCaptor = nullptr; - - return WIN_ERR_OK; - -} - -//------------------------------------------------------------------------------------------------- -/** Returns the current mouse captor. */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::winGetCapture() -{ - - return m_mouseCaptor; - -} - -//------------------------------------------------------------------------------------------------- -/** Gets the window pointer from its id */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::winGetWindowFromId( GameWindow *window, Int id ) -{ - - if( window == nullptr ) - window = m_windowList; - - for( ; window; window = window->m_next ) - { - - if( window->winGetWindowId() == id) - return window; - else if( window->m_child ) - { - GameWindow *child = winGetWindowFromId( window->m_child, id ); - - if( child ) - return child; - - } - - } - - return nullptr; - -} - -//------------------------------------------------------------------------------------------------- -/** Gets the Window List Pointer */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::winGetWindowList() -{ - - return m_windowList; - -} - -//------------------------------------------------------------------------------------------------- -/** Send a system message to the specified window */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType GameWindowManager::winSendSystemMsg( GameWindow *window, - UnsignedInt msg, - WindowMsgData mData1, - WindowMsgData mData2 ) -{ - - if( window == nullptr) - return MSG_IGNORED; - - if( msg != GWM_DESTROY && BitIsSet( window->m_status, WIN_STATUS_DESTROYED ) ) - return MSG_IGNORED; - - return window->m_system( window, msg, mData1, mData2 ); - -} - -//------------------------------------------------------------------------------------------------- -/** Send a system message to the specified window */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType GameWindowManager::winSendInputMsg( GameWindow *window, - UnsignedInt msg, - WindowMsgData mData1, - WindowMsgData mData2 ) -{ - - if( window == nullptr ) - return MSG_IGNORED; - - if( msg != GWM_DESTROY && BitIsSet( window->m_status, WIN_STATUS_DESTROYED ) ) - return MSG_IGNORED; - - return window->m_input( window, msg, mData1, mData2 ); - -} - -//------------------------------------------------------------------------------------------------- -/** Get the current input focus */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::winGetFocus() -{ - - return m_keyboardFocus; - -} - -//------------------------------------------------------------------------------------------------- -/** Set the current input focus */ -//------------------------------------------------------------------------------------------------- -Int GameWindowManager::winSetFocus( GameWindow *window ) -{ - Bool wantsFocus = FALSE; - - // if a window doesn't want keyboard focus don't give it - if( window ) - if( BitIsSet( window->winGetStatus(), WIN_STATUS_NO_FOCUS) ) - return 0; - - // - // Tell current focus window that it's losing focus - // unless we are trying to give focus to the current focus window - // - if( (m_keyboardFocus) && (m_keyboardFocus != window) ) - { - Bool wf; // dummy var, ignored, but must be passed - winSendSystemMsg( m_keyboardFocus, GWM_INPUT_FOCUS, FALSE, (WindowMsgData)&wf ); - } - - // Set focus to new window - m_keyboardFocus = window; - - // Tell new focus window that it has focus - if( m_keyboardFocus ) - { - - for (;;) - { - winSendSystemMsg( window, GWM_INPUT_FOCUS, TRUE, (WindowMsgData)&wantsFocus ); - if (wantsFocus) - break; - - window = window->winGetParent(); - if( window == nullptr ) - break; - } - - } - - // If new window doesn't want focus, set focus to nullptr - if( wantsFocus == FALSE ) - m_keyboardFocus = nullptr; - - return WIN_ERR_OK; - -} - -//------------------------------------------------------------------------------------------------- -/** Process key press through the GUI. */ -//------------------------------------------------------------------------------------------------- -WinInputReturnCode GameWindowManager::winProcessKey( UnsignedByte key, - UnsignedByte state ) -{ - WinInputReturnCode returnCode = WIN_INPUT_NOT_USED; - - // Check for keyboard focus and a legal key for sanity - if( m_keyboardFocus && (key != KEY_NONE) ) - { - GameWindow *win = m_keyboardFocus; - - returnCode = WIN_INPUT_USED; // assume input will be used - - // - // Pass the keystroke up the window hierarchy until it is - // processed or we reach the top level window - // - while( winSendInputMsg( win, GWM_CHAR, key, state ) == MSG_IGNORED ) - { - - win = win->winGetParent(); - if( win == nullptr ) - { - - returnCode = WIN_INPUT_NOT_USED; // oops, it wasn't used after all - break; - - } - - } - - } - - return returnCode; - -} - -//------------------------------------------------------------------------------------------------- -/** Process a single mouse event through the window system */ -//------------------------------------------------------------------------------------------------- -WinInputReturnCode GameWindowManager::winProcessMouseEvent( GameWindowMessage msg, - ICoord2D *mousePos, - void *data ) -{ - WinInputReturnCode returnCode = WIN_INPUT_NOT_USED; - Bool objectTooltip = FALSE; - UnsignedInt packedMouseCoords; - GameWindow *window = nullptr; - GameWindow *toolTipWindow = nullptr; - Int dx, dy; - Bool clearGrabWindow = FALSE; - - // pack mouse coords into one entity for message passing - packedMouseCoords = SHORTTOLONG( mousePos->x, mousePos->y ); - - // clear tooltip ... it will be reset if necessary - TheMouse->setCursorTooltip( UnicodeString::TheEmptyString ); - - // Check for mouse capture - if( m_mouseCaptor ) - { - - // no window grabbed as of yet - m_grabWindow = nullptr; - - // what what window within the captured window are we in - window = m_mouseCaptor->winPointInChild( mousePos->x, mousePos->y ); - - // - // send buttons, drags, wheels to the windows, we don't continually - // send mouse positions - // - if( sendMousePosMessages == TRUE || msg != GWM_MOUSE_POS ) - { - GameWindow *win = window; - - if( win ) - { - while( win != nullptr ) - { - - if( winSendInputMsg( win, msg, packedMouseCoords, 0 ) == MSG_HANDLED ) - { - - // if used clear the event - returnCode = WIN_INPUT_USED; - break; - - } - - // if we just tested mouseCaptor don't go any higher in the chain - if( win == m_mouseCaptor ) - break; - - win = win->winGetParent(); - - } - - } - else - { - - // if used clear the event - if( winSendInputMsg( m_mouseCaptor, msg, packedMouseCoords, 0 ) == MSG_HANDLED ) - returnCode = WIN_INPUT_USED; - - } - - } - - } - else - { - - if( m_grabWindow ) - { - GameWindow *parent; - - switch( msg ) - { - - // -------------------------------------------------------------------- - case GWM_LEFT_UP: - { - //Play a beep sound if the window is disabled. - m_grabWindow->winPointInChild( mousePos->x, mousePos->y, FALSE, TRUE ); - - BitClear( m_grabWindow->m_status, WIN_STATUS_ACTIVE ); - if( m_grabWindow->winPointInWindow( mousePos->x, mousePos->y ) ) - winSendInputMsg( m_grabWindow, GWM_LEFT_UP, packedMouseCoords, 0 ); - else if( BitIsSet( m_grabWindow->m_status, WIN_STATUS_DRAGGABLE )) - { - winSendInputMsg( m_grabWindow, GWM_LEFT_UP, packedMouseCoords, 0 ); - } - - clearGrabWindow = TRUE; - break; - - } - - // -------------------------------------------------------------------- - case MOUSE_EVENT_NONE: - case GWM_LEFT_DRAG: - { - - if( BitIsSet( m_grabWindow->m_status, WIN_STATUS_DRAGGABLE ) ) - { - ICoord2D *mouseDelta = (ICoord2D *)data; - dx = mouseDelta->x; - dy = mouseDelta->y; - - // Clip window to parent - if( m_grabWindow->winGetParent() ) - { - - parent = m_grabWindow->winGetParent(); - - if( m_grabWindow->m_region.lo.x + dx < 0 ) - dx = 0 - m_grabWindow->m_region.lo.x; - else if( m_grabWindow->m_region.hi.x + dx > parent->m_size.x ) - dx = parent->m_size.x - m_grabWindow->m_region.hi.x; - - if( m_grabWindow->m_region.lo.y + dy < 0 ) - dy = 0 - m_grabWindow->m_region.lo.y; - else if( m_grabWindow->m_region.hi.y + dy > parent->m_size.y ) - dy = parent->m_size.y - m_grabWindow->m_region.hi.y; - } - - // Move the window, but keep it completely visible within screen boundaries - IRegion2D newRegion; - ICoord2D grabSize; - - m_grabWindow->winGetPosition( &newRegion.lo.x, &newRegion.lo.y ); - m_grabWindow->winGetSize( &grabSize.x, &grabSize.y ); - - newRegion.lo.x += dx; - newRegion.lo.y += dy; - if( newRegion.lo.x < 0 ) - newRegion.lo.x = 0; - if( newRegion.lo.y < 0 ) - newRegion.lo.y = 0; - - newRegion.hi.x = newRegion.lo.x + grabSize.x; - newRegion.hi.y = newRegion.lo.y + grabSize.y; - if( newRegion.hi.x > (Int)TheDisplay->getWidth() ) - newRegion.hi.x = (Int)TheDisplay->getWidth(); - if( newRegion.hi.y > (Int)TheDisplay->getHeight() ) - newRegion.hi.y = (Int)TheDisplay->getHeight(); - - newRegion.lo.x = newRegion.hi.x - grabSize.x; - newRegion.lo.y = newRegion.hi.y - grabSize.y; - - m_grabWindow->winSetPosition( newRegion.lo.x, newRegion.lo.y ); - - } - - // Send mouse drag message - winSendInputMsg( m_grabWindow, msg, packedMouseCoords, 0 ); - break; - - } - - } - - // mark event handled - returnCode = WIN_INPUT_USED; - - } - else - { - - if( m_modalHead && m_modalHead->window ) - { - window = m_modalHead->window->winPointInChild( mousePos->x, mousePos->y ); - } - else - { - // search for top-level window which contains pointer - window = findWindowUnderMouse(toolTipWindow, mousePos, WIN_STATUS_ABOVE, WIN_STATUS_HIDDEN); - - // check !above, below and hidden - if( window == nullptr ) - window = findWindowUnderMouse(toolTipWindow, mousePos, WIN_STATUS_NONE, WIN_STATUS_ABOVE | WIN_STATUS_BELOW | WIN_STATUS_HIDDEN); - - // check below and !hidden - if( window == nullptr ) - window = findWindowUnderMouse(toolTipWindow, mousePos, WIN_STATUS_BELOW, WIN_STATUS_HIDDEN); - } - - if( window ) - if( BitIsSet( window->m_status, WIN_STATUS_NO_INPUT ) ) - { - if(window->winGetParent() && BitIsSet( window->winGetParent()->winGetInstanceData()->getStyle(), GWS_COMBO_BOX )) - window = window->winGetParent(); - else - window = nullptr; - } - - if( window ) - { - GameWindow *tempWin; - - // - // only send messages for button states, wheel states, we do not - // continually send messages for mouse positions - // - if( sendMousePosMessages == TRUE || msg != GWM_MOUSE_POS ) - { - - tempWin = window; - - // Give everyone a chance to do something with the clicks - GameWindow *oldLoneWindow = m_loneWindow; - while( winSendInputMsg( tempWin, msg, packedMouseCoords, 0 ) == MSG_IGNORED ) - { - - tempWin = tempWin->m_parent; - if( tempWin == nullptr ) - break; - - } - - - // First check to see if m_loneWindow is set if so, close the window - if( m_loneWindow && m_loneWindow == oldLoneWindow - &&( msg == GWM_LEFT_UP || msg == GWM_MIDDLE_UP || msg == GWM_RIGHT_UP || tempWin)) - { - if(!m_loneWindow->winIsChild(tempWin)) - winSetLoneWindow( nullptr ); - /* - ComboBoxData *cData = (ComboBoxData *)m_comboBoxOpen->winGetUserData(); - // verify that the window that ate the message wasn't one of our own - if(cData->dropDownButton != tempWin && - cData->editBox != tempWin && - cData->listBox != tempWin && - cData->listboxData->upButton != tempWin && - cData->listboxData->downButton != tempWin && - cData->listboxData->slider != tempWin && - cData->listboxData->slider != tempWin->winGetParent()) - winSetOpenComboBoxWindow( nullptr );*/ - - } - if( tempWin ) - { - - // - // Someone cares, if this is a left button down event - // it should get "grabbed" - /// @todo should allow for left handed mouse configs here? - // - if( msg == GWM_LEFT_DOWN ) - { - -// if( tempWin != windowList ) -// WinActivate( tempWin ); - m_grabWindow = tempWin; - - } - - // event is used - returnCode = WIN_INPUT_USED; - - } - - } - - } - - if( toolTipWindow == nullptr ) - { - - if( isHidden( window ) == FALSE ) - toolTipWindow = window; - - } - - // if tooltips are on set them into the window - Bool tooltipsOn = TRUE; - if( tooltipsOn ) - { -// if( toolTipWindow && toolTipWindow->winGetParent() && BitIsSet( toolTipWindow->winGetParent()->winGetInstanceData()->getStyle(), GWS_COMBO_BOX )) -// toolTipWindow = toolTipWindow->winGetParent(); - if( toolTipWindow ) - { - // do we have a callback to call for the tooltip - if( toolTipWindow->m_tooltip ) - toolTipWindow->m_tooltip( toolTipWindow, - &toolTipWindow->m_instData, - packedMouseCoords ); - - // else, do we have a normal tooltip to set - else if( toolTipWindow->m_instData.getTooltipTextLength() ) - TheMouse->setCursorTooltip( toolTipWindow->m_instData.getTooltipText(), toolTipWindow->m_instData.m_tooltipDelay ); - - } - else - { - - // - // not pointing at a window... perhaps we are pointing at a valid - // tooltip-able object in the game world ... let's set a flag so - // during the object testing we can set the tooltip, we can do - // whatever we like now that we know no other tooltip was set from - // a window - // - objectTooltip = TRUE; - - } - - } - - } - - } - - // - // check if new current window is different from the last - // but only if both windows fall within the mouseCaptor if one exists - // - if( (m_grabWindow == nullptr) && (window != m_currMouseRgn) ) - { - if( m_mouseCaptor ) - { - if( m_mouseCaptor->winIsChild( m_currMouseRgn ) ) - winSendInputMsg( m_currMouseRgn, GWM_MOUSE_LEAVING, packedMouseCoords, 0 ); - } - else if( m_currMouseRgn ) - winSendInputMsg( m_currMouseRgn, GWM_MOUSE_LEAVING, packedMouseCoords, 0 ); - - if( window ) - winSendInputMsg( window, GWM_MOUSE_ENTERING, packedMouseCoords, 0 ); - - m_currMouseRgn = window; - - } - - // clear grabWindow if necessary - if( clearGrabWindow == TRUE ) - { - - m_grabWindow = nullptr; - clearGrabWindow = FALSE; - - } - - return returnCode; - -} - -bool GameWindowManager::isMouseWithinWindow(GameWindow* window, const ICoord2D* mousePos, unsigned int requiredStatusMask, unsigned int forbiddenStatusMask) -{ - return ((BitIsSet(window->m_status, requiredStatusMask) || requiredStatusMask == 0) && - !BitIsSet(window->m_status, forbiddenStatusMask) && - mousePos->x >= window->m_region.lo.x && - mousePos->x <= window->m_region.hi.x && - mousePos->y >= window->m_region.lo.y && - mousePos->y <= window->m_region.hi.y); -} - -GameWindow* GameWindowManager::findWindowUnderMouse(GameWindow*& toolTipWindow, const ICoord2D* mousePos, unsigned int requiredStatusMask, unsigned int forbiddenStatusMask) -{ - for (GameWindow* window = m_windowList; window; window = window->m_next) - { - if (!isMouseWithinWindow(window, mousePos, requiredStatusMask, forbiddenStatusMask)) - continue; - - if (toolTipWindow == nullptr) - { - GameWindow* childWindow = window->winPointInAnyChild(mousePos->x, mousePos->y, TRUE, TRUE); - - if (childWindow->m_tooltip || childWindow->m_instData.getTooltipTextLength()) - toolTipWindow = childWindow; - } - - if (BitIsSet(window->m_status, WIN_STATUS_ENABLED)) - { - // determine which child window the mouse is in - return window->winPointInChild(mousePos->x, mousePos->y); - } - } - - return nullptr; -} - -//------------------------------------------------------------------------------------------------- -/** Draw a window and its children, in parent-first order. - * Children's coordinates are relative to their parents. - * Note that hidden windows automatically will not draw any - * of their children ... but see-thru windows only will not - * draw themselves, but will give their children an - * opportunity to draw */ -//------------------------------------------------------------------------------------------------- -Int GameWindowManager::drawWindow( GameWindow *window ) -{ - GameWindow *child; - - if( window == nullptr ) - return WIN_ERR_INVALID_WINDOW; - - if( BitIsSet( window->m_status, WIN_STATUS_HIDDEN ) == FALSE ) - { - - if( !BitIsSet( window->m_status, WIN_STATUS_SEE_THRU ) && window->m_draw ) - window->m_draw( window, &window->m_instData ); - - /// @todo visit list boxes and borders, this is stupid! - // for list boxes only draw the borders BEFORE the children - if( BitIsSet( window->winGetStyle(), GWS_SCROLL_LISTBOX ) ) - if( BitIsSet( window->m_status, WIN_STATUS_BORDER ) == TRUE && - !BitIsSet( window->m_status, WIN_STATUS_SEE_THRU ) ) - window->winDrawBorder(); - - // draw children in reverse order just like the window list - child = window->m_child; - while( child && child->m_next ) - child = child->m_next; - - for( ; child; child = child->m_prev ) - drawWindow( child ); - - // - // draw the border for the window AFTER the window contents AND the - // children contents have drawn - // - if( !BitIsSet( window->winGetStyle(), GWS_SCROLL_LISTBOX ) ) - if( BitIsSet( window->m_status, WIN_STATUS_BORDER ) == TRUE && - !BitIsSet( window->m_status, WIN_STATUS_SEE_THRU ) ) - window->winDrawBorder(); - - } - - return WIN_ERR_OK; - -} - -//------------------------------------------------------------------------------------------------- -/** Draw the GUI in reverse order to correlate with clicking priority */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::winRepaint() -{ - GameWindow *window, *next; - - // draw below windows - for( window = m_windowTail; window; window = next ) - { - next = window->m_prev; - - if( BitIsSet( window->m_status, WIN_STATUS_BELOW ) ) - drawWindow( window ); - } - - // draw non-above and non-below windows - for( window = m_windowTail; window; window = next ) - { - next = window->m_prev; - - if (BitIsSet( window->m_status, WIN_STATUS_ABOVE | - WIN_STATUS_BELOW ) == FALSE) - drawWindow( window ); - } - - // draw above windows - for( window = m_windowTail; window; window = next ) - { - next = window->m_prev; - - if( BitIsSet( window->m_status, WIN_STATUS_ABOVE ) ) - drawWindow( window ); - } - - if(TheTransitionHandler) - TheTransitionHandler->draw(); -} - -//------------------------------------------------------------------------------------------------- -/** Dump information about all the windows for resource problems */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::dumpWindow( GameWindow *window ) -{ -#ifndef FINAL - GameWindow *child; - - if( window == nullptr ) - return; - - DEBUG_LOG(( "ID: %d\tRedraw: 0x%08X\tUser Data: %d", - window->winGetWindowId(), window->m_draw, window->m_userData )); - - for( child = window->m_child; child; child = child->m_next ) - dumpWindow( child ); - - return; -#endif -} - -//------------------------------------------------------------------------------------------------- -/** Create a new window by setting up its parameters and callbacks. */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::winCreate( GameWindow *parent, - UnsignedInt status, - Int x, Int y, - Int width, Int height, - GameWinSystemFunc system, - WinInstanceData *instData ) -{ - GameWindow *window; - - // allocate new window - window = allocateNewWindow(); - if( window == nullptr ) - { - - DEBUG_LOG(( "WinCreate error: Could not allocate new window" )); -#ifndef FINAL - { - GameWindow *win; - - for( win = m_windowList; win; win = win->m_next ) - dumpWindow( win ); - } -#endif - - return nullptr; - - } - - // If this is a child window add it to the parent's window list - if( parent ) - addWindowToParent( window, parent ); - else - linkWindow( window ); - - window->m_status = status; - window->m_size.x = width; - window->m_size.y = height; - - window->m_region.lo.x = x; - window->m_region.lo.y = y; - window->m_region.hi.x = x + width; - window->m_region.hi.y = y + height; - - window->normalizeWindowRegion(); - - // set the system function and send a create message to window - window->winSetSystemFunc( system ); - winSendSystemMsg( window, GWM_CREATE, 0, 0 ); - - // copy over instance data if present - if( instData ) - window->winSetInstanceData( instData ); - - // set default font - if (TheGlobalLanguageData && TheGlobalLanguageData->m_defaultWindowFont.name.isNotEmpty()) - { window->winSetFont( winFindFont( - TheGlobalLanguageData->m_defaultWindowFont.name, - TheGlobalLanguageData->m_defaultWindowFont.size, - TheGlobalLanguageData->m_defaultWindowFont.bold) ); - } - else - window->winSetFont( winFindFont( "Times New Roman", 14, FALSE ) ); - - return window; - -} - -//------------------------------------------------------------------------------------------------- -/** Take a window and its children off the top level list and free - * their allocation class data. */ -//------------------------------------------------------------------------------------------------- -Int GameWindowManager::winDestroy( GameWindow *window ) -{ - GameWindow *child, *next; - - if( window == nullptr ) - return WIN_ERR_INVALID_WINDOW; - - // - // we should never have edit data allocated in the window code, it's - // completely handled by the editor ONLY - // - DEBUG_ASSERTCRASH( window->winGetEditData() == nullptr, - ("winDestroy(): edit data should NOT be present!") ); - - if( BitIsSet( window->m_status, WIN_STATUS_DESTROYED ) ) - return WIN_ERR_OK; - - BitSet( window->m_status, WIN_STATUS_DESTROYED ); - window->freeImages(); - - if( m_mouseCaptor == window ) - winRelease( window ); - - if( m_keyboardFocus == window ) - winSetFocus( nullptr ); - - if( (m_modalHead != nullptr) && (window == m_modalHead->window) ) - winUnsetModal( m_modalHead->window ); - - if( m_currMouseRgn == window ) - m_currMouseRgn = nullptr; - - if( m_grabWindow == window ) - m_grabWindow = nullptr; - - for( child = window->m_child; child; child = next ) - { - next = child->m_next; - winDestroy( child ); - } - - // Remove the top level window from list - if( window->m_parent == nullptr ) - unlinkWindow( window ); - else - unlinkChildWindow( window ); - - // Add to head of the destroy list - window->m_prev = nullptr; - window->m_next = m_destroyList; - - m_destroyList = window; - - // - // if this window is part of a layout screen, notify the screen that - // this window is going away - // - if( window->m_layout ) - window->m_layout->removeWindow( window ); - - return WIN_ERR_OK; - -} - -//------------------------------------------------------------------------------------------------- -/** Destroy all windows on the window list IMMEDIATELY */ -//------------------------------------------------------------------------------------------------- -Int GameWindowManager::winDestroyAll() -{ - GameWindow *win, *next; - - // - // NOTE that it is CRITICAL that the windows be destroyed this way, - // the editor has windows that are not on this main list that must - // exist throughout a reset of the system (copy/paste for instance) - // so DO NOT ever change this to a clever pool of memory for the - // windows and reset the _pool_ ... I will have to kill you! CBD - // - - for( next = win = m_windowList; next; win = next) - { - next = win->m_next; - - winDestroy( win ); - - } - - // Destroy All Windows just added to destroy list - processDestroyList(); - - return WIN_ERR_OK; - -} - -//------------------------------------------------------------------------------------------------- -/** Sets selected window into a modal state. This window will get - * put at the top of a modal stack */ -//------------------------------------------------------------------------------------------------- -Int GameWindowManager::winSetModal( GameWindow *window ) -{ - ModalWindow *modal; - - if( window == nullptr ) - return WIN_ERR_INVALID_WINDOW; - - // verify requesting window is a root window - if( window->m_parent != nullptr ) - { - DEBUG_LOG(( "WinSetModal: Non Root window attempted to go modal." )); - return WIN_ERR_INVALID_PARAMETER; // return error if not - } - // Allocate new Modal Window Entry - modal = newInstance(ModalWindow); - if( modal == nullptr ) - { - DEBUG_LOG(( "WinSetModal: Unable to allocate space for Modal Entry." )); - return WIN_ERR_GENERAL_FAILURE; - } - - // Put new entry at top of list - modal->window = window; - modal->next = m_modalHead; - m_modalHead = modal; - - return WIN_ERR_OK; - -} - -//------------------------------------------------------------------------------------------------- -/** pops window off of the modal stack. If this window is not the top - * of the modal stack an error will occur. */ -//------------------------------------------------------------------------------------------------- -Int GameWindowManager::winUnsetModal( GameWindow *window ) -{ - ModalWindow *next; - - if( window == nullptr ) - return WIN_ERR_INVALID_WINDOW; - - // verify entry is at top of list - if( (m_modalHead == nullptr) || (m_modalHead->window != window) ) - { - - // return error if not - DEBUG_LOG(( "WinUnsetModal: Invalid window attempting to unset modal (%d)", - window->winGetWindowId() )); - return WIN_ERR_GENERAL_FAILURE; - - } - - // remove from top of list - next = m_modalHead->next; - deleteInstance(m_modalHead); - m_modalHead = next; - - return WIN_ERR_OK; - -} - -//------------------------------------------------------------------------------------------------- -/** Get the grabbed window */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::winGetGrabWindow() -{ - - return m_grabWindow; - -} - -//------------------------------------------------------------------------------------------------- -/** Explicitly set the grab window */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::winSetGrabWindow( GameWindow *window ) -{ - - m_grabWindow = window; - -} - -//------------------------------------------------------------------------------------------------- -/** Explicitly set the grab window */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::winSetLoneWindow( GameWindow *window ) -{ - // ignore if we're trying to set the same window - if( m_loneWindow == window ) - return; - if( m_loneWindow ) - winSendSystemMsg( m_loneWindow, GGM_CLOSE, 0, 0 ); - m_loneWindow = window; - -} - -//------------------------------------------------------------------------------------------------- -/** Create a Modal Message Box */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::gogoMessageBox(Int x, Int y, Int width, Int height, UnsignedShort buttonFlags, - UnicodeString titleString, UnicodeString bodyString, - GameWinMsgBoxFunc yesCallback, - GameWinMsgBoxFunc noCallback, - GameWinMsgBoxFunc okCallback, - GameWinMsgBoxFunc cancelCallback ) -{ - return gogoMessageBox(x,y, width,height,buttonFlags,titleString,bodyString,yesCallback,noCallback,okCallback,cancelCallback, FALSE); -} - -GameWindow *GameWindowManager::gogoMessageBox(Int x, Int y, Int width, Int height, UnsignedShort buttonFlags, - UnicodeString titleString, UnicodeString bodyString, - GameWinMsgBoxFunc yesCallback, - GameWinMsgBoxFunc noCallback, - GameWinMsgBoxFunc okCallback, - GameWinMsgBoxFunc cancelCallback, Bool useLogo ) - -{ - // first check to make sure we have some buttons to display - if(buttonFlags == 0 ) - { - return nullptr; - } - GameWindow *trueParent = nullptr; - //Changed by Chris - if(useLogo) - trueParent = winCreateFromScript( "Menus/QuitMessageBox.wnd" ); - else - trueParent = winCreateFromScript( "Menus/MessageBox.wnd" ); - //Added By Chris - AsciiString menuName; - if(useLogo) - menuName.set("QuitMessageBox.wnd:"); - else - menuName.set("MessageBox.wnd:"); - - AsciiString tempName; - GameWindow *parent = nullptr; - - tempName = menuName; - tempName.concat("MessageBoxParent"); - parent = winGetWindowFromId(trueParent, TheNameKeyGenerator->nameToKey( tempName )); - winSetModal( trueParent ); - winSetFocus( nullptr ); // make sure we lose focus from other windows even if we refuse focus ourselves - winSetFocus( parent ); - - // If the user wants the size to be different then the default - float ratioX, ratioY = 1; - - if( width > 0 && height > 0 ) - { - ICoord2D temp; - //First grab the percent increase/decrease compared to the default size - parent->winGetSize( &temp.x, &temp.y); - ratioX = (float)width / (float)temp.x; - ratioY = (float)height / (float)temp.y; - //Set the window's new size - parent->winSetSize( width, height); - - //Resize/reposition all the children windows based off the ratio - GameWindow *child; - for( child = parent->winGetChild(); child; child = child->winGetNext() ) - { - child->winGetSize(&temp.x, &temp.y); - temp.x =Int(temp.x * ratioX); - temp.y =Int(temp.y * ratioY); - child->winSetSize(temp.x, temp.y); - - child->winGetPosition(&temp.x, &temp.y); - temp.x =Int(temp.x * ratioX); - temp.y =Int(temp.y * ratioY); - child->winSetPosition(temp.x, temp.y); - } - } - - // If the user wants to position the message box somewhere other then default - if( x >= 0 && y >= 0) - parent->winSetPosition(x, y); - - // Reposition the buttons - Int buttonX[3], buttonY[3]; - - //In the layout, buttonOk will be in the first button position - NameKeyType buttonOkID = NAMEKEY_INVALID; - - tempName = menuName; - tempName.concat("ButtonOk"); - buttonOkID = TheNameKeyGenerator->nameToKey( tempName ); - GameWindow *buttonOk = winGetWindowFromId(parent, buttonOkID); - buttonOk->winGetPosition(&buttonX[0], &buttonY[0]); - - tempName = menuName; - tempName.concat("ButtonYes"); - NameKeyType buttonYesID = TheNameKeyGenerator->nameToKey( tempName ); - GameWindow *buttonYes = winGetWindowFromId(parent, buttonYesID); - //buttonNo in the second position - tempName = menuName; - tempName.concat("ButtonNo"); - NameKeyType buttonNoID = TheNameKeyGenerator->nameToKey(tempName); - GameWindow *buttonNo = winGetWindowFromId(parent, buttonNoID); - buttonNo->winGetPosition(&buttonX[1], &buttonY[1]); - - //and buttonCancel in the third - tempName = menuName; - tempName.concat("ButtonCancel"); - NameKeyType buttonCancelID = TheNameKeyGenerator->nameToKey( tempName ); - GameWindow *buttonCancel = winGetWindowFromId(parent, buttonCancelID); - buttonCancel->winGetPosition(&buttonX[2], &buttonY[2]); - - //we shouldn't have button OK and Yes on the same dialog - if((buttonFlags & (MSG_BOX_OK | MSG_BOX_YES)) == (MSG_BOX_OK | MSG_BOX_YES) ) - { - DEBUG_CRASH(("Passed in MSG_BOX_OK and MSG_BOX_YES. Big No No.")); - } - - //Position the OK button if we have one - if( (buttonFlags & MSG_BOX_OK) == MSG_BOX_OK) - { - buttonOk->winSetPosition(buttonX[0], buttonY[0]); - buttonOk->winHide(FALSE); - } - else if( (buttonFlags & MSG_BOX_YES) == MSG_BOX_YES) - { - //Position the Yes if we have one - buttonYes->winSetPosition(buttonX[0], buttonY[0]); - buttonYes->winHide(FALSE); - } - - if((buttonFlags & (MSG_BOX_NO | MSG_BOX_CANCEL)) == (MSG_BOX_NO | MSG_BOX_CANCEL) ) - { - //If we have both the No and Cancel button, then the no should go in the middle position - buttonNo->winSetPosition(buttonX[1], buttonY[1]); - buttonCancel->winSetPosition(buttonX[2], buttonY[2]); - buttonNo->winHide(FALSE); - buttonCancel->winHide(FALSE); - } - else if( (buttonFlags & MSG_BOX_NO) == MSG_BOX_NO) - { - //if we just have the no button, then position it in the right most spot - buttonNo->winSetPosition(buttonX[2], buttonY[2]); - buttonNo->winHide(FALSE); - } - else if( (buttonFlags & MSG_BOX_CANCEL) == MSG_BOX_CANCEL) - { - //else if we just have the Cancel button, well, it should always go in the right spot - buttonCancel->winSetPosition(buttonX[2], buttonY[2]); - buttonCancel->winHide(FALSE); - } - - // Fill the text into the text boxes - tempName = menuName; - tempName.concat("StaticTextTitle"); - NameKeyType staticTextTitleID = TheNameKeyGenerator->nameToKey( tempName ); - GameWindow *staticTextTitle = winGetWindowFromId(parent, staticTextTitleID); - GadgetStaticTextSetText(staticTextTitle,titleString); - tempName = menuName; - tempName.concat("StaticTextMessage"); - NameKeyType staticTextMessageID = TheNameKeyGenerator->nameToKey( tempName ); - GameWindow *staticTextMessage = winGetWindowFromId(parent, staticTextMessageID); - GadgetStaticTextSetText(staticTextMessage,bodyString); - - // create a structure that will pass the functions to - WindowMessageBoxData *MsgBoxCallbacks = NEW WindowMessageBoxData; - MsgBoxCallbacks->cancelCallback = cancelCallback; - MsgBoxCallbacks->noCallback = noCallback; - MsgBoxCallbacks->okCallback = okCallback; - MsgBoxCallbacks->yesCallback = yesCallback; - //pass the structure to the dialog - trueParent->winSetUserData( MsgBoxCallbacks ); - - //make sure the dialog is showing and bring it to the top - parent->winHide(FALSE); - parent->winBringToTop(); - - //Changed By Chris - return trueParent; -} - -//------------------------------------------------------------------------------------------------- -/** Create a button GUI control */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::gogoGadgetPushButton( GameWindow *parent, - UnsignedInt status, - Int x, Int y, - Int width, Int height, - WinInstanceData *instData, - GameFont *defaultFont, - Bool defaultVisual ) -{ - GameWindow *button; - - // we MUST have a push button style window to do this - if( BitIsSet( instData->getStyle(), GWS_PUSH_BUTTON ) == FALSE ) - { - - DEBUG_LOG(( "Can't create button gadget, instance data not button type" )); - assert( 0 ); - return nullptr; - - } - - // create the button window - button = winCreate( parent, status, - x, y, width, height, - GadgetPushButtonSystem, - instData ); - if( button == nullptr ) - { - - DEBUG_LOG(( "Unable to create button for push button gadget" )); - assert( 0 ); - return nullptr; - - } - - // assign input function - button->winSetInputFunc( GadgetPushButtonInput ); - - // - // assign draw function, the draw functions must actually be implemented - // on the device level of the engine - // - if( BitIsSet( button->winGetStatus(), WIN_STATUS_IMAGE ) ) - button->winSetDrawFunc( getPushButtonImageDrawFunc() ); - else - button->winSetDrawFunc( getPushButtonDrawFunc() ); - - // set the owner to the parent, or if no parent it will be itself - button->winSetOwner( parent ); - - // Init the userdata to null - button->winSetUserData(nullptr); - - // assign the default images/colors - assignDefaultGadgetLook( button, defaultFont, defaultVisual ); - - // assign text from label - UnicodeString text = winTextLabelToText( instData->m_textLabelString ); - if( text.getLength() ) - GadgetButtonSetText( button, text ); - - return button; - -} - -//------------------------------------------------------------------------------------------------- -/** Create a checkbox UI element */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::gogoGadgetCheckbox( GameWindow *parent, - UnsignedInt status, - Int x, Int y, - Int width, Int height, - WinInstanceData *instData, - GameFont *defaultFont, - Bool defaultVisual ) - -{ - GameWindow *checkbox; - - // we MUST have a push button style window to do this - if( BitIsSet( instData->getStyle(), GWS_CHECK_BOX ) == FALSE ) - { - - DEBUG_LOG(( "Can't create checkbox gadget, instance data not checkbox type" )); - assert( 0 ); - return nullptr; - - } - - // create the button window - checkbox = winCreate( parent, status, - x, y, width, height, - GadgetCheckBoxSystem, - instData ); - if( checkbox == nullptr ) - { - - DEBUG_LOG(( "Unable to create checkbox window" )); - assert( 0 ); - return nullptr; - - } - - // assign input function - checkbox->winSetInputFunc( GadgetCheckBoxInput ); - - // - // assign draw function, the draw functions must actually be implemented - // on the device level of the engine - // - if( BitIsSet( checkbox->winGetStatus(), WIN_STATUS_IMAGE ) ) - checkbox->winSetDrawFunc( getCheckBoxImageDrawFunc() ); - else - checkbox->winSetDrawFunc( getCheckBoxDrawFunc() ); - - // set the owner to the parent, or if no parent it will be itself - checkbox->winSetOwner( parent ); - - // assign the default images/colors - assignDefaultGadgetLook( checkbox, defaultFont, defaultVisual ); - - // assign text from label - UnicodeString text = winTextLabelToText( instData->m_textLabelString ); - if( text.getLength() ) - GadgetCheckBoxSetText( checkbox, text ); - - return checkbox; - -} - -//------------------------------------------------------------------------------------------------- -/** Create a radio button GUI element */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::gogoGadgetRadioButton( GameWindow *parent, - UnsignedInt status, - Int x, Int y, - Int width, Int height, - WinInstanceData *instData, - RadioButtonData *rData, - GameFont *defaultFont, - Bool defaultVisual ) - -{ - GameWindow *radioButton; - RadioButtonData *radioData; - - // we MUST have a push button style window to do this - if( BitIsSet( instData->getStyle(), GWS_RADIO_BUTTON ) == FALSE ) - { - - DEBUG_LOG(( "Can't create radioButton gadget, instance data not radioButton type" )); - assert( 0 ); - return nullptr; - - } - - // create the button window - radioButton = winCreate( parent, status, - x, y, width, height, - GadgetRadioButtonSystem, - instData ); - if( radioButton == nullptr ) - { - - DEBUG_LOG(( "Unable to create radio button window" )); - assert( 0 ); - return nullptr; - - } - - // allocate and store the radio button user data - radioData = NEW RadioButtonData; - memcpy( radioData, rData, sizeof( RadioButtonData ) ); - radioButton->winSetUserData( radioData ); - - // assign input function - radioButton->winSetInputFunc( GadgetRadioButtonInput ); - - // - // assign draw function, the draw functions must actually be implemented - // on the device level of the engine - // - if( BitIsSet( radioButton->winGetStatus(), WIN_STATUS_IMAGE ) ) - radioButton->winSetDrawFunc( getRadioButtonImageDrawFunc() ); - else - radioButton->winSetDrawFunc( getRadioButtonDrawFunc() ); - - // set the owner to the parent, or if no parent it will be itself - radioButton->winSetOwner( parent ); - - // assign the default images/colors - assignDefaultGadgetLook( radioButton, defaultFont, defaultVisual ); - - // assign text from label - UnicodeString text = winTextLabelToText( instData->m_textLabelString ); - if( text.getLength() ) - GadgetRadioSetText( radioButton, text ); - - return radioButton; - -} - -//------------------------------------------------------------------------------------------------- -/** Create a tab control GUI element */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::gogoGadgetTabControl( GameWindow *parent, - UnsignedInt status, - Int x, Int y, - Int width, Int height, - WinInstanceData *instData, - TabControlData *tData, - GameFont *defaultFont, - Bool defaultVisual ) - -{ - GameWindow *tabControl; - TabControlData *tabData; - - // we MUST have a tab control style window to do this - if( BitIsSet( instData->getStyle(), GWS_TAB_CONTROL ) == FALSE ) - { - - DEBUG_LOG(( "Can't create tabControl gadget, instance data not tabControl type" )); - assert( 0 ); - return nullptr; - - } - - // create the tab control window - tabControl = winCreate( parent, status, - x, y, width, height, - GadgetTabControlSystem, - instData ); - if( tabControl == nullptr ) - { - - DEBUG_LOG(( "Unable to create tab control window" )); - assert( 0 ); - return nullptr; - - } - - // allocate and store the tab control user data - tabData = NEW TabControlData; - memcpy( tabData, tData, sizeof( TabControlData ) ); - tabControl->winSetUserData( tabData ); - - GadgetTabControlComputeTabRegion( tabControl ); - GadgetTabControlCreateSubPanes( tabControl ); - GadgetTabControlShowSubPane( tabControl, 0 ); - - // assign input function - tabControl->winSetInputFunc( GadgetTabControlInput ); - - // - // assign draw function, the draw functions must actually be implemented - // on the device level of the engine - // - if( BitIsSet( tabControl->winGetStatus(), WIN_STATUS_IMAGE ) ) - tabControl->winSetDrawFunc( getTabControlImageDrawFunc() ); - else - tabControl->winSetDrawFunc( getTabControlDrawFunc() ); - - // set the owner to the parent, or if no parent it will be itself - tabControl->winSetOwner( parent ); - - // assign the default images/colors - assignDefaultGadgetLook( tabControl, defaultFont, defaultVisual ); - - return tabControl; - -} - -//------------------------------------------------------------------------------------------------- -/** Create a list box GUI control */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::gogoGadgetListBox( GameWindow *parent, - UnsignedInt status, - Int x, Int y, - Int width, Int height, - WinInstanceData *instData, - ListboxData *listboxDataTemplate, - GameFont *defaultFont, - Bool defaultVisual ) - -{ - GameWindow *listbox; - ListboxData *listboxData; - Bool title = FALSE; - - // we MUST have a push button style window to do this - if( BitIsSet( instData->getStyle(), GWS_SCROLL_LISTBOX ) == FALSE ) - { - - DEBUG_LOG(( "Can't create listbox gadget, instance data not listbox type" )); - assert( 0 ); - return nullptr; - - } - - // create the listbox - listbox = winCreate( parent, status, x, y, width, height, - GadgetListBoxSystem, instData ); - - if( listbox == nullptr ) - { - - DEBUG_LOG(( "Unable to create listbox window" )); - assert( 0 ); - return nullptr; - - } - - // allocate the listbox data, copy template data over and set it into box - listboxData = NEW ListboxData; - DEBUG_ASSERTCRASH(listboxDataTemplate, ("listboxDataTemplate not initialized")); - memcpy( listboxData, listboxDataTemplate, sizeof( ListboxData ) ); - - // Add the list box data struct to the window's class data - listbox->winSetUserData( listboxData ); - - // set the owner to the parent, or if no parent it will be itself - listbox->winSetOwner( parent ); - - // Adjust for list title if present - if( instData->getTextLength() ) - title = TRUE; - - // Set up list box redraw callbacks - if( BitIsSet( listbox->winGetStatus(), WIN_STATUS_IMAGE )) - listbox->winSetDrawFunc( getListBoxImageDrawFunc() ); - else - listbox->winSetDrawFunc( getListBoxDrawFunc() ); - - // Set up list box input callbacks - if( listboxData->multiSelect ) - listbox->winSetInputFunc( GadgetListBoxMultiInput ); - else - listbox->winSetInputFunc( GadgetListBoxInput ); - - - - // - // allocate and set the list length, note that setting the list length will - // automatically allocate the selection entries that are needed for multi - // select list boxes etc. - // - Int length = listboxData->listLength; - listboxData->listLength = 0; // hacky! - GadgetListBoxSetListLength( listbox, length ); - - // store display height - listboxData->displayHeight = height; - - if( title ) - listboxData->displayHeight -= winFontHeight( instData->getFont() ); - - // Set display position to the top of the list - listboxData->displayPos = 0; - listboxData->selectPos = -1; - listboxData->doubleClickTime = 0; - listboxData->insertPos = 0; - listboxData->endPos = 0; - listboxData->totalHeight = 0; - - // if this listbox has multiple selections prep it - //if( listboxData->multiSelect ) - // GadgetListBoxAddMultiSelect( listbox ); - - // If ScrollBar was requested ... create it. - if( listboxData->scrollBar ) - GadgetListboxCreateScrollbar( listbox ); - // - // Setup listbox Columns - // - if( listboxData->columns == 1 ) - { - listboxData->columnWidth = NEW Int[listboxData->columns]; - listboxData->columnWidth[0] = width; - if( listboxData->slider ) - { - ICoord2D sliderSize; - - listboxData->slider->winGetSize( &sliderSize.x, &sliderSize.y ); - listboxData->columnWidth[0] -= (sliderSize.x + 2); - - } - } - else - { - if( !listboxData->columnWidthPercentage ) - return nullptr; - listboxData->columnWidth = NEW Int[listboxData->columns]; - if(!listboxData->columnWidth) - return nullptr; - - Int totalWidth = width; - if( listboxData->slider ) - { - ICoord2D sliderSize; - - listboxData->slider->winGetSize( &sliderSize.x, &sliderSize.y ); - totalWidth -= (sliderSize.x + 2); - - } - for(Int i = 0; i < listboxData->columns; i++ ) - { - listboxData->columnWidth[i] = listboxData->columnWidthPercentage[i] * totalWidth / 100; - } - } - // assign the default images/colors - assignDefaultGadgetLook( listbox, defaultFont, defaultVisual ); - - return listbox; - -} - -//------------------------------------------------------------------------------------------------- -/** Does all generic window creation, calls appropriate slider create - * function to set up slider-specific data */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::gogoGadgetSlider( GameWindow *parent, - UnsignedInt status, - Int x, Int y, - Int width, Int height, - WinInstanceData *instData, - SliderData *sliderData, - GameFont *defaultFont, - Bool defaultVisual ) - -{ - GameWindow *slider; - GameWindow *button; - SliderData *data; - - // - // All sliders need to have the tab stop status in order for - // the focus chain to work correctly. - // - BitSet( status, WIN_STATUS_TAB_STOP ); - - if( BitIsSet( instData->getStyle(), GWS_HORZ_SLIDER ) ) - { - - slider = winCreate( parent, status, x, y, width, height, - GadgetHorizontalSliderSystem, instData ); - - // Set up horizontal slider callbacks - slider->winSetInputFunc( GadgetHorizontalSliderInput ); - if( BitIsSet( slider->winGetStatus(), WIN_STATUS_IMAGE ) ) - slider->winSetDrawFunc( getHorizontalSliderImageDrawFunc() ); - else - slider->winSetDrawFunc( getHorizontalSliderDrawFunc() ); - - } - else if ( BitIsSet( instData->getStyle(), GWS_VERT_SLIDER ) ) - { - - slider = winCreate( parent, status, x, y, width, height, - GadgetVerticalSliderSystem, instData ); - - // Set up vertical slider callbacks - slider->winSetInputFunc( GadgetVerticalSliderInput ); - - if( BitIsSet( slider->winGetStatus(), WIN_STATUS_IMAGE ) && !(parent && BitIsSet(parent->winGetStyle(), GWS_SCROLL_LISTBOX))) - slider->winSetDrawFunc( getVerticalSliderImageDrawFunc() ); - else - slider->winSetDrawFunc( getVerticalSliderDrawFunc() ); - - } - else - { - - DEBUG_LOG(( "gogoGadgetSlider warning: unrecognized slider style." )); - assert( 0 ); - return nullptr; - - } - - // sanity - if( slider == nullptr ) - { - - DEBUG_LOG(( "Unable to create slider control window" )); - assert( 0 ); - return nullptr; - - } - - // set the owner to the parent, or if no parent it will be itself - slider->winSetOwner( parent ); - - // create the slider thumb button - WinInstanceData buttonInstData; - UnsignedInt statusFlags = status | WIN_STATUS_ENABLED | WIN_STATUS_DRAGGABLE; - - buttonInstData.init(); - - // if parent is hidden we don't need to be. - BitClear( statusFlags, WIN_STATUS_HIDDEN ); - - buttonInstData.m_owner = slider; - buttonInstData.m_style = GWS_PUSH_BUTTON; - - // if slider tracks, so will this sub control - if( BitIsSet( instData->getStyle(), GWS_MOUSE_TRACK ) ) - BitSet( buttonInstData.m_style, GWS_MOUSE_TRACK ); - - if( BitIsSet( instData->getStyle(), GWS_HORZ_SLIDER ) ) - button = gogoGadgetPushButton( slider, statusFlags, 0, HORIZONTAL_SLIDER_THUMB_POSITION, - HORIZONTAL_SLIDER_THUMB_WIDTH, HORIZONTAL_SLIDER_THUMB_HEIGHT, &buttonInstData, nullptr, TRUE ); - else - button = gogoGadgetPushButton( slider, statusFlags, 0, 0, - width, width+1, &buttonInstData, nullptr, TRUE ); - - // Protect against divide by zero - if( sliderData->maxVal == sliderData->minVal ) - sliderData->maxVal = sliderData->minVal + 1; - - if( BitIsSet( instData->getStyle(), GWS_HORZ_SLIDER ) ) - { - sliderData->numTicks = (float)(width - HORIZONTAL_SLIDER_THUMB_WIDTH) / - (float)(sliderData->maxVal - sliderData->minVal); - } else - { - sliderData->numTicks = (float)(height - GADGET_SIZE) / - (float)(sliderData->maxVal - sliderData->minVal); - } - - data = NEW SliderData; - memcpy( data, sliderData, sizeof(SliderData) ); - - // Add the slider data struct to the window's class data - slider->winSetUserData( data ); - - // assign the default images/colors - assignDefaultGadgetLook( slider, defaultFont, defaultVisual ); - - return slider; - -} - -//------------------------------------------------------------------------------------------------- -/** Create a Combo Box GUI element */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::gogoGadgetComboBox( GameWindow *parent, - UnsignedInt status, - Int x, Int y, - Int width, Int height, - WinInstanceData *instData, - ComboBoxData *comboBoxDataTemplate, - GameFont *defaultFont, - Bool defaultVisual ) -{ - GameWindow *comboBox; - ComboBoxData *comboBoxData; - Bool title = FALSE; - - // we MUST have a push button style window to do this - if( BitIsSet( instData->getStyle(), GWS_COMBO_BOX) == FALSE ) - { - - DEBUG_LOG(( "Can't create ComboBox gadget, instance data not ComboBox type" )); - assert( 0 ); - return nullptr; - - } - - // create the listbox - comboBox = winCreate( parent, status, x, y, width, height, - GadgetComboBoxSystem, instData ); - - if( comboBox == nullptr ) - { - - DEBUG_LOG(( "Unable to create ComboBox window" )); - assert( 0 ); - return nullptr; - - } - - -// begin here - // allocate the listbox data, copy template data over and set it into box - comboBoxData = NEW ComboBoxData; - memcpy( comboBoxData, comboBoxDataTemplate, sizeof( ComboBoxData ) ); - - // Add the list box data struct to the window's class data - comboBox->winSetUserData( comboBoxData ); - - // set the owner to the parent, or if no parent it will be itself - comboBox->winSetOwner( parent ); - - // Adjust for list title if present - if( instData->getTextLength() ) - title = TRUE; - - // Set up list box redraw callbacks - if( BitIsSet( comboBox->winGetStatus(), WIN_STATUS_IMAGE )) - comboBox->winSetDrawFunc( getComboBoxImageDrawFunc() ); - else - comboBox->winSetDrawFunc( getComboBoxDrawFunc() ); - - // Set up list box input callbacks - comboBox->winSetInputFunc( GadgetComboBoxInput ); - - //Create the windows that make up - - - WinInstanceData winInstData; - Int buttonWidth, buttonHeight; - Int fontHeight; - Int top; - Int bottom; - - - // do we have a title - if( comboBox->winGetTextLength() ) - title = TRUE; - - // remove unwanted status bits. - status &= ~(WIN_STATUS_BORDER | WIN_STATUS_HIDDEN); - - fontHeight = winFontHeight( comboBox->winGetFont() ); - top = title ? (fontHeight + 1):0; - bottom = title ? (height - (fontHeight + 1)):height; - - // initialize instData - winInstData.init(); - - // size of button - buttonWidth = 21; - buttonHeight = 22; - - // ---------------------------------------------------------------------- - // Create Drop Down Button - // ---------------------------------------------------------------------- - - winInstData.m_owner = comboBox; - winInstData.m_style = GWS_PUSH_BUTTON; - - // if listbox tracks, so will this sub control - if( BitIsSet( comboBox->winGetStyle(), GWS_MOUSE_TRACK ) ) - BitSet( winInstData.m_style, GWS_MOUSE_TRACK ); - - comboBoxData->dropDownButton = - gogoGadgetPushButton( comboBox, - status | WIN_STATUS_ACTIVE | WIN_STATUS_ENABLED, - width - buttonWidth, 0, - buttonWidth, height, - &winInstData, nullptr, TRUE ); - comboBoxData->dropDownButton->winSetTooltipFunc(comboBox->winGetTooltipFunc()); - comboBoxData->dropDownButton->winSetTooltip(instData->getTooltipText()); - comboBoxData->dropDownButton->setTooltipDelay(comboBox->getTooltipDelay()); - // ---------------------------------------------------------------------- - // Create text entry - // ---------------------------------------------------------------------- - UnsignedInt statusTextEntry; - winInstData.init(); - - winInstData.m_owner = comboBox; - winInstData.m_style |= GWS_ENTRY_FIELD; - winInstData.m_textLabelString = "Entry"; - if( BitIsSet( comboBox->winGetStyle(), GWS_MOUSE_TRACK ) ) - BitSet( winInstData.m_style, GWS_MOUSE_TRACK ); - if( comboBoxData->isEditable) - { - statusTextEntry = status; - } - else - { - statusTextEntry = status | WIN_STATUS_NO_INPUT ;//| WIN_STATUS_NO_FOCUS; - comboBoxData->entryData->drawTextFromStart = TRUE; - } - comboBoxData->editBox = gogoGadgetTextEntry( comboBox, statusTextEntry , - 0,0 , - width - buttonWidth , height , - &winInstData, comboBoxData->entryData, - winInstData.m_font, FALSE ); - comboBoxData->editBox->winSetTooltipFunc(comboBox->winGetTooltipFunc()); - comboBoxData->editBox->winSetTooltip(instData->getTooltipText()); - comboBoxData->editBox->setTooltipDelay(comboBox->getTooltipDelay()); - - delete (comboBoxData->entryData); - comboBoxData->entryData = (EntryData *)comboBoxData->editBox->winGetUserData(); - // ---------------------------------------------------------------------- - // Create list box - // ---------------------------------------------------------------------- - winInstData.init(); - - winInstData.m_owner = comboBox; - if( BitIsSet( comboBox->winGetStyle(), GWS_MOUSE_TRACK ) ) - BitSet( winInstData.m_style, GWS_MOUSE_TRACK ); - BitSet( winInstData.m_style, WIN_STATUS_HIDDEN ); - winInstData.m_style |= GWS_SCROLL_LISTBOX; - status &= ~(WIN_STATUS_IMAGE); - comboBoxData->listBox = gogoGadgetListBox( comboBox, status | WIN_STATUS_ABOVE | WIN_STATUS_ONE_LINE, 0, height, - width, height, - &winInstData, comboBoxData->listboxData, - winInstData.m_font, FALSE ); - comboBoxData->listBox->winHide(TRUE); - delete(comboBoxData->listboxData); - comboBoxData->listboxData = (ListboxData *)comboBoxData->listBox->winGetUserData(); - - comboBoxData->listBox->winSetTooltipFunc(comboBox->winGetTooltipFunc()); - comboBoxData->listBox->winSetTooltip(instData->getTooltipText()); - comboBoxData->listBox->setTooltipDelay(comboBox->getTooltipDelay()); - GadgetListBoxSetAudioFeedback(comboBoxData->listBox, TRUE); - - // Initialize the ComboBox's variables and the controls with them - GadgetComboBoxSetIsEditable(comboBox, comboBoxData->isEditable); - GadgetComboBoxSetMaxChars( comboBox, comboBoxData->maxChars ); - GadgetComboBoxSetMaxDisplay( comboBox, comboBoxData->maxDisplay ); - - //Initialize the control's text colors - Color color, border; - - color = comboBox->winGetEnabledTextColor(); - border = comboBox->winGetEnabledTextBorderColor(); - if(comboBoxData->listBox) - comboBoxData->listBox->winSetEnabledTextColors( color,border); - if(comboBoxData->editBox) - comboBoxData->editBox->winSetEnabledTextColors(color,border); - - color = comboBox->winGetDisabledTextColor(); - border = comboBox->winGetDisabledTextBorderColor(); - if(comboBoxData->listBox) - comboBoxData->listBox->winSetDisabledTextColors( color,border); - if(comboBoxData->editBox) - comboBoxData->editBox->winSetDisabledTextColors(color,border); - - - color = comboBox->winGetHiliteTextColor(); - border = comboBox->winGetHiliteTextBorderColor(); - if(comboBoxData->listBox) - comboBoxData->listBox->winSetHiliteTextColors( color,border); - if(comboBoxData->editBox) - comboBoxData->editBox->winSetHiliteTextColors(color,border); - - comboBoxData->dontHide = FALSE; - - // assign the default images/colors - assignDefaultGadgetLook( comboBox, defaultFont, defaultVisual ); - - return comboBox; - -} - -//------------------------------------------------------------------------------------------------- -/** Create a progress bar GUI element */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::gogoGadgetProgressBar( GameWindow *parent, - UnsignedInt status, - Int x, Int y, - Int width, Int height, - WinInstanceData *instData, - GameFont *defaultFont, - Bool defaultVisual ) - -{ - GameWindow *progressBar; - - // we MUST have a push button style window to do this - if( BitIsSet( instData->getStyle(), GWS_PROGRESS_BAR ) == FALSE ) - { - - DEBUG_LOG(( "Can't create progressBar gadget, instance data not progressBar type" )); - assert( 0 ); - return nullptr; - - } - - // create the button window - progressBar = winCreate( parent, status, - x, y, width, height, - GadgetProgressBarSystem, - instData ); - if( progressBar == nullptr ) - { - - DEBUG_LOG(( "Unable to create progress bar control" )); - assert( 0 ); - return nullptr; - - } - - // - // assign draw function, the draw functions must actually be implemented - // on the device level of the engine - // - if( BitIsSet( progressBar->winGetStatus(), WIN_STATUS_IMAGE ) ) - progressBar->winSetDrawFunc( getProgressBarImageDrawFunc() ); - else - progressBar->winSetDrawFunc( getProgressBarDrawFunc() ); - - // set the owner to the parent, or if no parent it will be itself - progressBar->winSetOwner( parent ); - - // assign the default images/colors - assignDefaultGadgetLook( progressBar, defaultFont, defaultVisual ); - - return progressBar; - -} - -//------------------------------------------------------------------------------------------------- -/** Does all generic window creation, calls appropriate text field create - * function to set up specific data */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::gogoGadgetStaticText( GameWindow *parent, - UnsignedInt status, - Int x, Int y, - Int width, Int height, - WinInstanceData *instData, - TextData *textData, - GameFont *defaultFont, - Bool defaultVisual ) - -{ - GameWindow *textWin; - TextData *data; - - // Static Text can not be a Tab Stop - BitClear( instData->m_style, GWS_TAB_STOP ); - - if( BitIsSet( instData->getStyle(), GWS_STATIC_TEXT ) ) - { - textWin = winCreate( parent, status, x, y, width, height, - GadgetStaticTextSystem, instData ); - } - else - { - DEBUG_LOG(( "gogoGadgetText warning: unrecognized text style." )); - return nullptr; - } - - if( textWin != nullptr ) - { - - // set the owner to the parent, or if no parent it will be itself - textWin->winSetOwner( parent ); - - // assign callbacks - textWin->winSetInputFunc( GadgetStaticTextInput ); - if( BitIsSet( textWin->winGetStatus(), WIN_STATUS_IMAGE ) ) - textWin->winSetDrawFunc( getStaticTextImageDrawFunc() ); - else - textWin->winSetDrawFunc( getStaticTextDrawFunc() ); - - data = NEW TextData; - assert( textData != nullptr ); - memcpy( data, textData, sizeof(TextData) ); - - // allocate a display string for the tet - data->text = TheDisplayStringManager->newDisplayString(); - // set whether or not we center the wrapped text - data->text->setWordWrapCentered( BitIsSet( instData->getStatus(), WIN_STATUS_WRAP_CENTERED )); - // Add the entry field data struct to the window's class data - textWin->winSetUserData( data ); - - // assign the default images/colors - assignDefaultGadgetLook( textWin, defaultFont, defaultVisual ); - - // assign text from label - UnicodeString text = winTextLabelToText( instData->m_textLabelString ); - if( text.getLength() ) - GadgetStaticTextSetText( textWin, text ); - - } - - return textWin; - -} - -//------------------------------------------------------------------------------------------------- -/** Does all generic window creation, calls appropriate entry field create - * function to set up specific data */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::gogoGadgetTextEntry( GameWindow *parent, - UnsignedInt status, - Int x, Int y, - Int width, Int height, - WinInstanceData *instData, - EntryData *entryData, - GameFont *defaultFont, - Bool defaultVisual ) - -{ - GameWindow *entry; - EntryData *data; - - if( BitIsSet( instData->getStyle(), GWS_ENTRY_FIELD ) == FALSE ) - { - - DEBUG_LOG(( "Unable to create text entry, style not entry type" )); - assert( 0 ); - return nullptr; - - } - - // create the window - entry = winCreate( parent, status, x, y, width, height, - GadgetTextEntrySystem, instData ); - if( entry == nullptr ) - { - - DEBUG_LOG(( "Unable to create text entry window" )); - assert( 0 ); - return nullptr; - - } - - // set owner of this control - entry->winSetOwner( parent ); - - // assign callbacks - entry->winSetInputFunc( GadgetTextEntryInput ); - if( BitIsSet( entry->winGetStatus(), WIN_STATUS_IMAGE ) ) - entry->winSetDrawFunc( getTextEntryImageDrawFunc() ); - else - entry->winSetDrawFunc( getTextEntryDrawFunc() ); - - // zero entry data -// memset( entryData->text, 0, ENTRY_TEXT_LEN ); -// memset( entryData->constructText, 0, ENTRY_TEXT_LEN ); - - // initialize character positions, lengths etc - if( entryData->text ) - entryData->charPos = entryData->text->getTextLength(); - else - entryData->charPos = 0; - entryData->conCharPos = 0; - entryData->receivedUnichar = FALSE; - if( entryData->maxTextLen > ENTRY_TEXT_LEN ) - entryData->maxTextLen = ENTRY_TEXT_LEN; - - // allocate entry data - data = NEW EntryData; - - // copy over data control - memcpy( data, entryData, sizeof(EntryData) ); - - // allocate new text display string - data->text = TheDisplayStringManager->newDisplayString(); - data->sText = TheDisplayStringManager->newDisplayString(); - data->constructText = TheDisplayStringManager->newDisplayString(); - - // set the max for the text lengths -// data->text->allocateFixed( ENTRY_TEXT_LEN ); -// data->sText->allocateFixed( ENTRY_TEXT_LEN ); - - // do any real display string copies - if( entryData->text ) - data->text->setText( entryData->text->getText() ); - if( entryData->sText ) - data->sText->setText( entryData->sText->getText() ); - - // set data into window - entry->winSetUserData( data ); - - // asian languages get to have list box kanji character completion - data->constructList = nullptr; - if( OurLanguage == LANGUAGE_ID_KOREAN || - OurLanguage == LANGUAGE_ID_JAPANESE ) - { - // we need to create the construct listbox - WinInstanceData boxInstData; - ListboxData lData; - - // initialize instData - boxInstData.init(); - - // define display region - memset( &lData, 0, sizeof(ListboxData) ); - lData.listLength = 128; - lData.autoScroll = FALSE; - lData.scrollIfAtEnd = FALSE; - lData.autoPurge = TRUE; - lData.scrollBar = TRUE; - lData.multiSelect = FALSE; - lData.columns = 1; - lData.columnWidth = nullptr; - - boxInstData.m_style = GWS_SCROLL_LISTBOX | GWS_MOUSE_TRACK; - - data->constructList = gogoGadgetListBox( nullptr, - WIN_STATUS_ABOVE | - WIN_STATUS_HIDDEN | - WIN_STATUS_NO_FOCUS | - WIN_STATUS_ONE_LINE, - 0, height, - 110, 119, - &boxInstData, - &lData, - nullptr, - TRUE ); - - if( data->constructList == nullptr ) - { - - DEBUG_LOG(( "gogoGadgetEntry warning: Failed to create listbox." )); - assert( 0 ); - winDestroy( entry ); - return nullptr; - - } - - } - - // assign the default images/colors - assignDefaultGadgetLook( entry, defaultFont, defaultVisual ); - - // assign text from label - UnicodeString text = winTextLabelToText( instData->m_textLabelString ); - if( text.getLength() ) - GadgetTextEntrySetText( entry, text ); - - return entry; - -} - -//------------------------------------------------------------------------------------------------- -/** Use this method to assign the default images/colors to gadgets as - * they area created */ -//------------------------------------------------------------------------------------------------- -void GameWindowManager::assignDefaultGadgetLook( GameWindow *gadget, - GameFont *defaultFont, - Bool assignVisual ) -{ - UnsignedByte alpha = 255; - static Color red = winMakeColor( 255, 0, 0, alpha ); - static Color darkRed = winMakeColor( 128, 0, 0, alpha ); - static Color lightRed = winMakeColor( 255, 128, 128, alpha ); - static Color green = winMakeColor( 0, 255, 0, alpha ); - static Color darkGreen = winMakeColor( 0, 128, 0, alpha ); - static Color lightGreen = winMakeColor( 128, 255, 128, alpha ); - static Color blue = winMakeColor( 0, 0, 255, alpha ); - static Color darkBlue = winMakeColor( 0, 0, 128, alpha ); - static Color lightBlue = winMakeColor( 128, 128, 255, alpha ); - static Color purple = winMakeColor( 255, 0, 255, alpha ); - static Color darkPurple = winMakeColor( 128, 0, 128, alpha ); - static Color lightPurple= winMakeColor( 255, 128, 255, alpha ); - static Color yellow = winMakeColor( 255, 255, 0, alpha ); - static Color darkYellow = winMakeColor( 128, 128, 0, alpha ); - static Color lightYellow= winMakeColor( 255, 255, 128, alpha ); - static Color cyan = winMakeColor( 0, 255, 255, alpha ); - static Color darkCyan = winMakeColor( 64, 128, 128, alpha ); - static Color lightCyan = winMakeColor( 128, 255, 255, alpha ); - static Color gray = winMakeColor( 128, 128, 128, alpha ); - static Color darkGray = winMakeColor( 64, 64, 64, alpha ); - static Color lightGray = winMakeColor( 192, 192, 192, alpha ); - static Color black = winMakeColor( 0, 0, 0, alpha ); - static Color white = winMakeColor( 254, 254, 254, alpha ); - static Color enabledText = white; - static Color enabledTextBorder = darkGray; - static Color disabledText = darkGray; - static Color disabledTextBorder = black; - static Color hiliteText = lightBlue; - static Color hiliteTextBorder = blue; - static Color imeCompositeText = green; - static Color imeCompositeTextBorder = blue; - WinInstanceData *instData; - - // sanity - if( gadget == nullptr ) - return; - - // get instance data - instData = gadget->winGetInstanceData(); - - // set default font - if( defaultFont ) - gadget->winSetFont( defaultFont ); - else - { - if (TheGlobalLanguageData && TheGlobalLanguageData->m_defaultWindowFont.name.isNotEmpty()) - { gadget->winSetFont( winFindFont( - TheGlobalLanguageData->m_defaultWindowFont.name, - TheGlobalLanguageData->m_defaultWindowFont.size, - TheGlobalLanguageData->m_defaultWindowFont.bold) ); - } - else - gadget->winSetFont( winFindFont( "Times New Roman", 14, FALSE ) ); - } - - // if we don't want to assign default colors/images get out of here - if( assignVisual == FALSE ) - return; - - // create images for the correct gadget type - if( BitIsSet( instData->getStyle(), GWS_PUSH_BUTTON ) ) - { - - // enabled background - GadgetButtonSetEnabledImage( gadget, winFindImage( "PushButtonEnabled" ) ); - GadgetButtonSetEnabledColor( gadget, red ); - GadgetButtonSetEnabledBorderColor( gadget, lightRed ); - // enabled selected button - GadgetButtonSetEnabledSelectedImage( gadget, winFindImage( "PushButtonEnabledSelected" ) ); - GadgetButtonSetEnabledSelectedColor( gadget, yellow ); - GadgetButtonSetEnabledSelectedBorderColor( gadget, white ); - - // Disabled background - GadgetButtonSetDisabledImage( gadget, winFindImage( "PushButtonDisabled" ) ); - GadgetButtonSetDisabledColor( gadget, gray ); - GadgetButtonSetDisabledBorderColor( gadget, lightGray ); - // Disabled selected button - GadgetButtonSetDisabledSelectedImage( gadget, winFindImage( "PushButtonDisabledSelected" ) ); - GadgetButtonSetDisabledSelectedColor( gadget, lightGray ); - GadgetButtonSetDisabledSelectedBorderColor( gadget, gray ); - - // Hilite background - GadgetButtonSetHiliteImage( gadget, winFindImage( "PushButtonHilite" ) ); - GadgetButtonSetHiliteColor( gadget, green ); - GadgetButtonSetHiliteBorderColor( gadget, darkGreen ); - // Hilite selected button - GadgetButtonSetHiliteSelectedImage( gadget, winFindImage( "PushButtonHiliteSelected" ) ); - GadgetButtonSetHiliteSelectedColor( gadget, yellow ); - GadgetButtonSetHiliteSelectedBorderColor( gadget, white ); - - // set default text colors for the gadget - gadget->winSetEnabledTextColors( enabledText, enabledTextBorder ); - gadget->winSetDisabledTextColors( disabledText, disabledTextBorder ); - gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder ); - gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder ); - - } - else if( BitIsSet( instData->getStyle(), GWS_CHECK_BOX ) ) - { - - // enabled background - GadgetCheckBoxSetEnabledImage( gadget, winFindImage( "CheckBoxEnabled" ) ); - GadgetCheckBoxSetEnabledColor( gadget, red ); - GadgetCheckBoxSetEnabledBorderColor( gadget, lightRed ); - // enabled CheckBox unselected - GadgetCheckBoxSetEnabledUncheckedBoxImage( gadget, winFindImage( "CheckBoxEnabledBoxUnselected" ) ); - GadgetCheckBoxSetEnabledUncheckedBoxColor( gadget, WIN_COLOR_UNDEFINED ); - GadgetCheckBoxSetEnabledUncheckedBoxBorderColor( gadget, lightBlue ); - // enabled CheckBox selected - GadgetCheckBoxSetEnabledCheckedBoxImage( gadget, winFindImage( "CheckBoxEnabledBoxSelected" ) ); - GadgetCheckBoxSetEnabledCheckedBoxColor( gadget, blue ); - GadgetCheckBoxSetEnabledCheckedBoxBorderColor( gadget, lightBlue ); - - // disabled background - GadgetCheckBoxSetDisabledImage( gadget, winFindImage( "CheckBoxDisabled" ) ); - GadgetCheckBoxSetDisabledColor( gadget, gray ); - GadgetCheckBoxSetDisabledBorderColor( gadget, lightGray ); - // Disabled CheckBox unselected - GadgetCheckBoxSetDisabledUncheckedBoxImage( gadget, winFindImage( "CheckBoxDisabledBoxUnselected" ) ); - GadgetCheckBoxSetDisabledUncheckedBoxColor( gadget, WIN_COLOR_UNDEFINED ); - GadgetCheckBoxSetDisabledUncheckedBoxBorderColor( gadget, lightGray ); - // Disabled CheckBox selected - GadgetCheckBoxSetDisabledCheckedBoxImage( gadget, winFindImage( "CheckBoxDisabledBoxSelected" ) ); - GadgetCheckBoxSetDisabledCheckedBoxColor( gadget, darkGray ); - GadgetCheckBoxSetDisabledCheckedBoxBorderColor( gadget, white ); - - // Hilite background - GadgetCheckBoxSetHiliteImage( gadget, winFindImage( "CheckBoxHilite" ) ); - GadgetCheckBoxSetHiliteColor( gadget, green ); - GadgetCheckBoxSetHiliteBorderColor( gadget, lightGreen ); - // Hilite CheckBox unselected - GadgetCheckBoxSetHiliteUncheckedBoxImage( gadget, winFindImage( "CheckBoxHiliteBoxUnselected" ) ); - GadgetCheckBoxSetHiliteUncheckedBoxColor( gadget, WIN_COLOR_UNDEFINED ); - GadgetCheckBoxSetHiliteUncheckedBoxBorderColor( gadget, lightBlue ); - // Hilite CheckBox selected - GadgetCheckBoxSetHiliteCheckedBoxImage( gadget, winFindImage( "CheckBoxHiliteBoxSelected" ) ); - GadgetCheckBoxSetHiliteCheckedBoxColor( gadget, yellow ); - GadgetCheckBoxSetHiliteCheckedBoxBorderColor( gadget, white ); - - // set default text colors for the gadget - gadget->winSetEnabledTextColors( enabledText, enabledTextBorder ); - gadget->winSetDisabledTextColors( disabledText, disabledTextBorder ); - gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder ); - gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder ); - - } - else if( BitIsSet( instData->getStyle(), GWS_RADIO_BUTTON ) ) - { - - // enabled background - GadgetRadioSetEnabledImage( gadget, winFindImage( "RadioButtonEnabled" ) ); - GadgetRadioSetEnabledColor( gadget, red ); - GadgetRadioSetEnabledBorderColor( gadget, lightRed ); - // enabled radio unselected - GadgetRadioSetEnabledUncheckedBoxImage( gadget, winFindImage( "RadioButtonEnabledBoxUnselected" ) ); - GadgetRadioSetEnabledUncheckedBoxColor( gadget, darkRed ); - GadgetRadioSetEnabledUncheckedBoxBorderColor( gadget, black ); - // enabled radio selected - GadgetRadioSetEnabledCheckedBoxImage( gadget, winFindImage( "RadioButtonEnabledBoxSelected" ) ); - GadgetRadioSetEnabledCheckedBoxColor( gadget, blue ); - GadgetRadioSetEnabledCheckedBoxBorderColor( gadget, lightBlue ); - - // disabled background - GadgetRadioSetDisabledImage( gadget, winFindImage( "RadioButtonDisabled" ) ); - GadgetRadioSetDisabledColor( gadget, gray ); - GadgetRadioSetDisabledBorderColor( gadget, lightGray ); - // Disabled radio unselected - GadgetRadioSetDisabledUncheckedBoxImage( gadget, winFindImage( "RadioButtonDisabledBoxUnselected" ) ); - GadgetRadioSetDisabledUncheckedBoxColor( gadget, gray ); - GadgetRadioSetDisabledUncheckedBoxBorderColor( gadget, lightGray ); - // Disabled radio selected - GadgetRadioSetDisabledCheckedBoxImage( gadget, winFindImage( "RadioButtonDisabledBoxSelected" ) ); - GadgetRadioSetDisabledCheckedBoxColor( gadget, darkGray ); - GadgetRadioSetDisabledCheckedBoxBorderColor( gadget, white ); - - // Hilite background - GadgetRadioSetHiliteImage( gadget, winFindImage( "RadioButtonHilite" ) ); - GadgetRadioSetHiliteColor( gadget, green ); - GadgetRadioSetHiliteBorderColor( gadget, lightGreen ); - // Hilite radio unselected - GadgetRadioSetHiliteUncheckedBoxImage( gadget, winFindImage( "RadioButtonHiliteBoxUnselected" ) ); - GadgetRadioSetHiliteUncheckedBoxColor( gadget, darkGreen ); - GadgetRadioSetHiliteUncheckedBoxBorderColor( gadget, lightGreen ); - // Hilite radio selected - GadgetRadioSetHiliteCheckedBoxImage( gadget, winFindImage( "RadioButtonHiliteBoxSelected" ) ); - GadgetRadioSetHiliteCheckedBoxColor( gadget, yellow ); - GadgetRadioSetHiliteCheckedBoxBorderColor( gadget, white ); - - // set default text colors for the gadget - gadget->winSetEnabledTextColors( enabledText, enabledTextBorder ); - gadget->winSetDisabledTextColors( disabledText, disabledTextBorder ); - gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder ); - gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder ); - - } - else if( BitIsSet( instData->getStyle(), GWS_HORZ_SLIDER ) ) - { - - // enabled - GadgetSliderSetEnabledImageLeft( gadget, winFindImage( "HSliderEnabledLeftEnd" ) ); - GadgetSliderSetEnabledImageRight( gadget, winFindImage( "HSliderEnabledRightEnd" ) ); - GadgetSliderSetEnabledImageCenter( gadget, winFindImage( "HSliderEnabledRepeatingCenter" ) ); - GadgetSliderSetEnabledImageSmallCenter( gadget, winFindImage( "HSliderEnabledSmallRepeatingCenter" ) ); - GadgetSliderSetEnabledColor( gadget, red ); - GadgetSliderSetEnabledBorderColor( gadget, lightRed ); - - // disabled - GadgetSliderSetDisabledImageLeft( gadget, winFindImage( "HSliderDisabledLeftEnd" ) ); - GadgetSliderSetDisabledImageRight( gadget, winFindImage( "HSliderDisabledRightEnd" ) ); - GadgetSliderSetDisabledImageCenter( gadget, winFindImage( "HSliderDisabledRepeatingCenter" ) ); - GadgetSliderSetDisabledImageSmallCenter( gadget, winFindImage( "HSliderDisabledSmallRepeatingCenter" ) ); - GadgetSliderSetDisabledColor( gadget, red ); - GadgetSliderSetDisabledBorderColor( gadget, lightRed ); - - // hilite - GadgetSliderSetHiliteImageLeft( gadget, winFindImage( "HSliderHiliteLeftEnd" ) ); - GadgetSliderSetHiliteImageRight( gadget, winFindImage( "HSliderHiliteRightEnd" ) ); - GadgetSliderSetHiliteImageCenter( gadget, winFindImage( "HSliderHiliteRepeatingCenter" ) ); - GadgetSliderSetHiliteImageSmallCenter( gadget, winFindImage( "HSliderHiliteSmallRepeatingCenter" ) ); - GadgetSliderSetHiliteColor( gadget, red ); - GadgetSliderSetHiliteBorderColor( gadget, lightRed ); - - // set default text colors for the gadget - gadget->winSetEnabledTextColors( enabledText, enabledTextBorder ); - gadget->winSetDisabledTextColors( disabledText, disabledTextBorder ); - gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder ); - gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder ); - - // - // set the default colors and images for the slider thumb - // - // enabled - GadgetSliderSetEnabledThumbImage( gadget, winFindImage( "HSliderThumbEnabled" ) ); - GadgetSliderSetEnabledThumbColor( gadget, GadgetSliderGetEnabledColor( gadget ) ); - GadgetSliderSetEnabledThumbBorderColor( gadget, GadgetSliderGetEnabledBorderColor( gadget ) ); - GadgetSliderSetEnabledSelectedThumbImage( gadget, winFindImage( "HSliderThumbEnabled" ) ); - GadgetSliderSetEnabledSelectedThumbColor( gadget, GadgetSliderGetEnabledBorderColor( gadget ) ); - GadgetSliderSetEnabledSelectedThumbBorderColor( gadget, GadgetSliderGetEnabledColor( gadget ) ); - - // disabled - GadgetSliderSetDisabledThumbImage( gadget, winFindImage( "HSliderThumbDisabled" ) ); - GadgetSliderSetDisabledThumbColor( gadget, GadgetSliderGetDisabledColor( gadget ) ); - GadgetSliderSetDisabledThumbBorderColor( gadget, GadgetSliderGetDisabledBorderColor( gadget ) ); - GadgetSliderSetDisabledSelectedThumbImage( gadget, winFindImage( "HSliderThumbDisabled" ) ); - GadgetSliderSetDisabledSelectedThumbColor( gadget, GadgetSliderGetDisabledBorderColor( gadget ) ); - GadgetSliderSetDisabledSelectedThumbBorderColor( gadget, GadgetSliderGetDisabledColor( gadget ) ); - - // hilite - GadgetSliderSetHiliteThumbImage( gadget, winFindImage( "HSliderThumbHilite" ) ); - GadgetSliderSetHiliteThumbColor( gadget, GadgetSliderGetHiliteColor( gadget ) ); - GadgetSliderSetHiliteThumbBorderColor( gadget, GadgetSliderGetHiliteBorderColor( gadget ) ); - GadgetSliderSetHiliteSelectedThumbImage( gadget, winFindImage( "HSliderThumbHiliteSelected" ) ); - GadgetSliderSetHiliteSelectedThumbColor( gadget, GadgetSliderGetHiliteBorderColor( gadget ) ); - GadgetSliderSetHiliteSelectedThumbBorderColor( gadget, GadgetSliderGetHiliteColor( gadget ) ); - - - } - else if( BitIsSet( instData->getStyle(), GWS_VERT_SLIDER ) ) - { - // enabled - GadgetSliderSetEnabledImageTop( gadget, winFindImage( "VSliderEnabledTopEnd" ) ); - GadgetSliderSetEnabledImageBottom( gadget, winFindImage( "VSliderEnabledBottomEnd" ) ); - GadgetSliderSetEnabledImageCenter( gadget, winFindImage( "VSliderEnabledRepeatingCenter" ) ); - GadgetSliderSetEnabledImageSmallCenter( gadget, winFindImage( "VSliderEnabledSmallRepeatingCenter" ) ); - GadgetSliderSetEnabledColor( gadget, red ); - GadgetSliderSetEnabledBorderColor( gadget, lightRed ); - - // disabled - GadgetSliderSetDisabledImageTop( gadget, winFindImage( "VSliderDisabledTopEnd" ) ); - GadgetSliderSetDisabledImageBottom( gadget, winFindImage( "VSliderDisabledBottomEnd" ) ); - GadgetSliderSetDisabledImageCenter( gadget, winFindImage( "VSliderDisabledRepeatingCenter" ) ); - GadgetSliderSetDisabledImageSmallCenter( gadget, winFindImage( "VSliderDisabledSmallRepeatingCenter" ) ); - GadgetSliderSetDisabledColor( gadget, red ); - GadgetSliderSetDisabledBorderColor( gadget, lightRed ); - - // hilite - GadgetSliderSetHiliteImageTop( gadget, winFindImage( "VSliderHiliteTopEnd" ) ); - GadgetSliderSetHiliteImageBottom( gadget, winFindImage( "VSliderHiliteBottomEnd" ) ); - GadgetSliderSetHiliteImageCenter( gadget, winFindImage( "VSliderHiliteRepeatingCenter" ) ); - GadgetSliderSetHiliteImageSmallCenter( gadget, winFindImage( "VSliderHiliteSmallRepeatingCenter" ) ); - GadgetSliderSetHiliteColor( gadget, red ); - GadgetSliderSetHiliteBorderColor( gadget, lightRed ); - - // set default text colors for the gadget - gadget->winSetEnabledTextColors( enabledText, enabledTextBorder ); - gadget->winSetDisabledTextColors( disabledText, disabledTextBorder ); - gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder ); - gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder ); - - // - // set the default colors and images for the slider thumb - // - // enabled - GadgetSliderSetEnabledThumbImage( gadget, winFindImage( "VSliderThumbEnabled" ) ); - GadgetSliderSetEnabledThumbColor( gadget, GadgetSliderGetEnabledColor( gadget ) ); - GadgetSliderSetEnabledThumbBorderColor( gadget, GadgetSliderGetEnabledBorderColor( gadget ) ); - GadgetSliderSetEnabledSelectedThumbImage( gadget, winFindImage( "VSliderThumbEnabled" ) ); - GadgetSliderSetEnabledSelectedThumbColor( gadget, GadgetSliderGetEnabledBorderColor( gadget ) ); - GadgetSliderSetEnabledSelectedThumbBorderColor( gadget, GadgetSliderGetEnabledColor( gadget ) ); - - // disabled - GadgetSliderSetDisabledThumbImage( gadget, winFindImage( "VSliderThumbDisabled" ) ); - GadgetSliderSetDisabledThumbColor( gadget, GadgetSliderGetDisabledColor( gadget ) ); - GadgetSliderSetDisabledThumbBorderColor( gadget, GadgetSliderGetDisabledBorderColor( gadget ) ); - GadgetSliderSetDisabledSelectedThumbImage( gadget, winFindImage( "VSliderThumbDisabled" ) ); - GadgetSliderSetDisabledSelectedThumbColor( gadget, GadgetSliderGetDisabledBorderColor( gadget ) ); - GadgetSliderSetDisabledSelectedThumbBorderColor( gadget, GadgetSliderGetDisabledColor( gadget ) ); - - // hilite - GadgetSliderSetHiliteThumbImage( gadget, winFindImage( "VSliderThumbHilite" ) ); - GadgetSliderSetHiliteThumbColor( gadget, GadgetSliderGetHiliteColor( gadget ) ); - GadgetSliderSetHiliteThumbBorderColor( gadget, GadgetSliderGetHiliteBorderColor( gadget ) ); - GadgetSliderSetHiliteSelectedThumbImage( gadget, winFindImage( "VSliderThumbHiliteSelected" ) ); - GadgetSliderSetHiliteSelectedThumbColor( gadget, GadgetSliderGetHiliteBorderColor( gadget ) ); - GadgetSliderSetHiliteSelectedThumbBorderColor( gadget, GadgetSliderGetHiliteColor( gadget ) ); - - } - else if( BitIsSet( instData->getStyle(), GWS_SCROLL_LISTBOX ) ) - { - ListboxData *listboxData = (ListboxData *)gadget->winGetUserData(); - - // set the colors - GadgetListBoxSetColors( gadget, - red, // enabled - lightRed, // enabled border - yellow, // enabled selected item - white, // enabled selected item border - gray, // disabled - lightGray, // disabled border - lightGray, // disabled selected item - white, // disabled selected item border - green, // hilite - darkGreen, // hilite border - white, // hilite selected item - darkGreen ); // hilite selected item border - - // now set the images - - // enabled - GadgetListBoxSetEnabledImage( gadget, winFindImage( "ListBoxEnabled" ) ); - GadgetListBoxSetEnabledSelectedItemImageLeft( gadget, winFindImage( "ListBoxEnabledSelectedItemLeftEnd" ) ); - GadgetListBoxSetEnabledSelectedItemImageRight( gadget, winFindImage( "ListBoxEnabledSelectedItemRightEnd" ) ); - GadgetListBoxSetEnabledSelectedItemImageCenter( gadget, winFindImage( "ListBoxEnabledSelectedItemRepeatingCenter" ) ); - GadgetListBoxSetEnabledSelectedItemImageSmallCenter( gadget, winFindImage( "ListBoxEnabledSelectedItemSmallRepeatingCenter" ) ); - - // disabled - GadgetListBoxSetDisabledImage( gadget, winFindImage( "ListBoxDisabled" ) ); - GadgetListBoxSetDisabledSelectedItemImageLeft( gadget, winFindImage( "ListBoxDisabledSelectedItemLeftEnd" ) ); - GadgetListBoxSetDisabledSelectedItemImageRight( gadget, winFindImage( "ListBoxDisabledSelectedItemRightEnd" ) ); - GadgetListBoxSetDisabledSelectedItemImageCenter( gadget, winFindImage( "ListBoxDisabledSelectedItemRepeatingCenter" ) ); - GadgetListBoxSetDisabledSelectedItemImageSmallCenter( gadget, winFindImage( "ListBoxDisabledSelectedItemSmallRepeatingCenter" ) ); - - - // hilited - GadgetListBoxSetHiliteImage( gadget, winFindImage( "ListBoxHilite" ) ); - GadgetListBoxSetHiliteSelectedItemImageLeft( gadget, winFindImage( "ListBoxHiliteSelectedItemLeftEnd" ) ); - GadgetListBoxSetHiliteSelectedItemImageRight( gadget, winFindImage( "ListBoxHiliteSelectedItemRightEnd" ) ); - GadgetListBoxSetHiliteSelectedItemImageCenter( gadget, winFindImage( "ListBoxHiliteSelectedItemRepeatingCenter" ) ); - GadgetListBoxSetHiliteSelectedItemImageSmallCenter( gadget, winFindImage( "ListBoxHiliteSelectedItemSmallRepeatingCenter" ) ); - - // assign default slider colors and images as part of the list box - GameWindow *slider = listboxData->slider; - if( slider ) - { - GameWindow *upButton = listboxData->upButton; - GameWindow *downButton = listboxData->downButton; - - // slider and slider thumb ---------------------------------------------- - - // enabled - GadgetSliderSetEnabledImageTop( slider, winFindImage( "VSliderLargeEnabledTopEnd" ) ); - GadgetSliderSetEnabledImageBottom( slider, winFindImage( "VSliderLargeEnabledBottomEnd" ) ); - GadgetSliderSetEnabledImageCenter( slider, winFindImage( "VSliderLargeEnabledRepeatingCenter" ) ); - GadgetSliderSetEnabledImageSmallCenter( slider, winFindImage( "VSliderLargeEnabledSmallRepeatingCenter" ) ); - GadgetSliderSetEnabledThumbImage( slider, winFindImage( "VSliderLargeThumbEnabled" ) ); - GadgetSliderSetEnabledSelectedThumbImage( slider, winFindImage( "VSliderLargeThumbEnabled" ) ); - - // disabled - GadgetSliderSetDisabledImageTop( slider, winFindImage( "VSliderLargeDisabledTopEnd" ) ); - GadgetSliderSetDisabledImageBottom( slider, winFindImage( "VSliderLargeDisabledBottomEnd" ) ); - GadgetSliderSetDisabledImageCenter( slider, winFindImage( "VSliderLargeDisabledRepeatingCenter" ) ); - GadgetSliderSetDisabledImageSmallCenter( slider, winFindImage( "VSliderLargeDisabledSmallRepeatingCenter" ) ); - GadgetSliderSetDisabledThumbImage( slider, winFindImage( "VSliderLargeThumbDisabled" ) ); - GadgetSliderSetDisabledSelectedThumbImage( slider, winFindImage( "VSliderLargeThumbDisabled" ) ); - - // hilite - GadgetSliderSetHiliteImageTop( slider, winFindImage( "VSliderLargeHiliteTopEnd" ) ); - GadgetSliderSetHiliteImageBottom( slider, winFindImage( "VSliderLargeHiliteBottomEnd" ) ); - GadgetSliderSetHiliteImageCenter( slider, winFindImage( "VSliderLargeHiliteRepeatingCenter" ) ); - GadgetSliderSetHiliteImageSmallCenter( slider, winFindImage( "VSliderLargeHiliteSmallRepeatingCenter" ) ); - GadgetSliderSetHiliteThumbImage( slider, winFindImage( "VSliderLargeThumbHilite" ) ); - GadgetSliderSetHiliteSelectedThumbImage( slider, winFindImage( "VSliderLargeThumbHilite" ) ); - - // up button ------------------------------------------------------------ - - // enabled - GadgetButtonSetEnabledImage( upButton, winFindImage( "VSliderLargeUpButtonEnabled" ) ); - GadgetButtonSetEnabledSelectedImage( upButton, winFindImage( "VSliderLargeUpButtonEnabled" ) ); - - // disabled - GadgetButtonSetDisabledImage( upButton, winFindImage( "VSliderLargeUpButtonDisabled" ) ); - GadgetButtonSetDisabledSelectedImage( upButton, winFindImage( "VSliderLargeUpButtonDisabled" ) ); - - // hilite - GadgetButtonSetHiliteImage( upButton, winFindImage( "VSliderLargeUpButtonHilite" ) ); - GadgetButtonSetHiliteSelectedImage( upButton, winFindImage( "VSliderLargeUpButtonHiliteSelected" ) ); - - // down button ---------------------------------------------------------- - - // enabled - GadgetButtonSetEnabledImage( downButton, winFindImage( "VSliderLargeDownButtonEnabled" ) ); - GadgetButtonSetEnabledSelectedImage( downButton, winFindImage( "VSliderLargeDownButtonEnabled" ) ); - - // disabled - GadgetButtonSetDisabledImage( downButton, winFindImage( "VSliderLargeDownButtonDisabled" ) ); - GadgetButtonSetDisabledSelectedImage( downButton, winFindImage( "VSliderLargeDownButtonDisabled" ) ); - - // hilite - GadgetButtonSetHiliteImage( downButton, winFindImage( "VSliderLargeDownButtonHilite" ) ); - GadgetButtonSetHiliteSelectedImage( downButton, winFindImage( "VSliderLargeDownButtonHiliteSelected" ) ); - - } - - } - else if( BitIsSet( instData->getStyle(), GWS_COMBO_BOX ) ) - { -// ComboBoxData *comboBoxData = (ComboBoxData *)gadget->winGetUserData(); - - GadgetComboBoxSetColors( gadget, - red, // enabled - lightRed, // enabled border - yellow, // enabled selected item - white, // enabled selected item border - gray, // disabled - lightGray, // disabled border - lightGray, // disabled selected item - white, // disabled selected item border - green, // hilite - darkGreen, // hilite border - white, // hilite selected item - darkGreen ); // hilite selected item border - - // enabled - GadgetComboBoxSetEnabledImage( gadget, winFindImage( "ListBoxEnabled" ) ); - GadgetComboBoxSetEnabledSelectedItemImageLeft( gadget, winFindImage( "ListBoxEnabledSelectedItemLeftEnd" ) ); - GadgetComboBoxSetEnabledSelectedItemImageRight( gadget, winFindImage( "ListBoxEnabledSelectedItemRightEnd" ) ); - GadgetComboBoxSetEnabledSelectedItemImageCenter( gadget, winFindImage( "ListBoxEnabledSelectedItemRepeatingCenter" ) ); - GadgetComboBoxSetEnabledSelectedItemImageSmallCenter( gadget, winFindImage( "ListBoxEnabledSelectedItemSmallRepeatingCenter" ) ); - - // disabled - GadgetComboBoxSetDisabledImage( gadget, winFindImage( "ListBoxDisabled" ) ); - GadgetComboBoxSetDisabledSelectedItemImageLeft( gadget, winFindImage( "ListBoxDisabledSelectedItemLeftEnd" ) ); - GadgetComboBoxSetDisabledSelectedItemImageRight( gadget, winFindImage( "ListBoxDisabledSelectedItemRightEnd" ) ); - GadgetComboBoxSetDisabledSelectedItemImageCenter( gadget, winFindImage( "ListBoxDisabledSelectedItemRepeatingCenter" ) ); - GadgetComboBoxSetDisabledSelectedItemImageSmallCenter( gadget, winFindImage( "ListBoxDisabledSelectedItemSmallRepeatingCenter" ) ); - - - // hilited - GadgetComboBoxSetHiliteImage( gadget, winFindImage( "ListBoxHilite" ) ); - GadgetComboBoxSetHiliteSelectedItemImageLeft( gadget, winFindImage( "ListBoxHiliteSelectedItemLeftEnd" ) ); - GadgetComboBoxSetHiliteSelectedItemImageRight( gadget, winFindImage( "ListBoxHiliteSelectedItemRightEnd" ) ); - GadgetComboBoxSetHiliteSelectedItemImageCenter( gadget, winFindImage( "ListBoxHiliteSelectedItemRepeatingCenter" ) ); - GadgetComboBoxSetHiliteSelectedItemImageSmallCenter( gadget, winFindImage( "ListBoxHiliteSelectedItemSmallRepeatingCenter" ) ); - - gadget->winSetEnabledTextColors( enabledText, enabledTextBorder ); - gadget->winSetDisabledTextColors( disabledText, disabledTextBorder ); - gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder ); - gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder ); - - GameWindow *dropDownButton = GadgetComboBoxGetDropDownButton( gadget ); - if ( dropDownButton ) - { - // enabled background - GadgetButtonSetEnabledImage( dropDownButton, winFindImage( "PushButtonEnabled" ) ); - // enabled selected button - GadgetButtonSetEnabledSelectedImage( dropDownButton, winFindImage( "PushButtonEnabledSelected" ) ); - - // Disabled background - GadgetButtonSetDisabledImage( dropDownButton, winFindImage( "PushButtonDisabled" ) ); - // Disabled selected button - GadgetButtonSetDisabledSelectedImage( dropDownButton, winFindImage( "PushButtonDisabledSelected" ) ); - - // Hilite background - GadgetButtonSetHiliteImage( dropDownButton, winFindImage( "PushButtonHilite" ) ); - // Hilite selected button - GadgetButtonSetHiliteSelectedImage( dropDownButton, winFindImage( "PushButtonHiliteSelected" ) ); - - } - - GameWindow *editBox = GadgetComboBoxGetEditBox( gadget ); - if ( editBox ) - { - // enabled - GadgetTextEntrySetEnabledImageLeft( editBox, winFindImage( "TextEntryEnabledLeftEnd" ) ); - GadgetTextEntrySetEnabledImageRight( editBox, winFindImage( "TextEntryEnabledRightEnd" ) ); - GadgetTextEntrySetEnabledImageCenter( editBox, winFindImage( "TextEntryEnabledRepeatingCenter" ) ); - GadgetTextEntrySetEnabledImageSmallCenter( editBox, winFindImage( "TextEntryEnabledSmallRepeatingCenter" ) ); - - // disabled - GadgetTextEntrySetDisabledImageLeft( editBox, winFindImage( "TextEntryDisabledLeftEnd" ) ); - GadgetTextEntrySetDisabledImageRight( editBox, winFindImage( "TextEntryDisabledRightEnd" ) ); - GadgetTextEntrySetDisabledImageCenter( editBox, winFindImage( "TextEntryDisabledRepeatingCenter" ) ); - GadgetTextEntrySetDisabledImageSmallCenter( editBox, winFindImage( "TextEntryDisabledSmallRepeatingCenter" ) ); - - // hilited - GadgetTextEntrySetHiliteImageLeft( editBox, winFindImage( "TextEntryHiliteLeftEnd" ) ); - GadgetTextEntrySetHiliteImageRight( editBox, winFindImage( "TextEntryHiliteRightEnd" ) ); - GadgetTextEntrySetHiliteImageCenter( editBox, winFindImage( "TextEntryHiliteRepeatingCenter" ) ); - GadgetTextEntrySetHiliteImageSmallCenter( editBox, winFindImage( "TextEntryHiliteSmallRepeatingCenter" ) ); - - } - - GameWindow * listBox = GadgetComboBoxGetListBox( gadget ); - if ( listBox ) - { - - // now set the images - - // enabled - GadgetListBoxSetEnabledImage( listBox, winFindImage( "ListBoxEnabled" ) ); - GadgetListBoxSetEnabledSelectedItemImageLeft( listBox, winFindImage( "ListBoxEnabledSelectedItemLeftEnd" ) ); - GadgetListBoxSetEnabledSelectedItemImageRight( listBox, winFindImage( "ListBoxEnabledSelectedItemRightEnd" ) ); - GadgetListBoxSetEnabledSelectedItemImageCenter( listBox, winFindImage( "ListBoxEnabledSelectedItemRepeatingCenter" ) ); - GadgetListBoxSetEnabledSelectedItemImageSmallCenter( listBox, winFindImage( "ListBoxEnabledSelectedItemSmallRepeatingCenter" ) ); - - // disabled - GadgetListBoxSetDisabledImage( listBox, winFindImage( "ListBoxDisabled" ) ); - GadgetListBoxSetDisabledSelectedItemImageLeft( listBox, winFindImage( "ListBoxDisabledSelectedItemLeftEnd" ) ); - GadgetListBoxSetDisabledSelectedItemImageRight( listBox, winFindImage( "ListBoxDisabledSelectedItemRightEnd" ) ); - GadgetListBoxSetDisabledSelectedItemImageCenter( listBox, winFindImage( "ListBoxDisabledSelectedItemRepeatingCenter" ) ); - GadgetListBoxSetDisabledSelectedItemImageSmallCenter( listBox, winFindImage( "ListBoxDisabledSelectedItemSmallRepeatingCenter" ) ); - - - // hilited - GadgetListBoxSetHiliteImage( listBox, winFindImage( "ListBoxHilite" ) ); - GadgetListBoxSetHiliteSelectedItemImageLeft( listBox, winFindImage( "ListBoxHiliteSelectedItemLeftEnd" ) ); - GadgetListBoxSetHiliteSelectedItemImageRight( listBox, winFindImage( "ListBoxHiliteSelectedItemRightEnd" ) ); - GadgetListBoxSetHiliteSelectedItemImageCenter( listBox, winFindImage( "ListBoxHiliteSelectedItemRepeatingCenter" ) ); - GadgetListBoxSetHiliteSelectedItemImageSmallCenter( listBox, winFindImage( "ListBoxHiliteSelectedItemSmallRepeatingCenter" ) ); - - // assign default slider colors and images as part of the list box - GameWindow *slider = GadgetListBoxGetSlider( listBox ); - if( slider ) - { - GameWindow *upButton = GadgetListBoxGetUpButton( listBox ); - GameWindow *downButton = GadgetListBoxGetDownButton( listBox ); - - // slider and slider thumb ---------------------------------------------- - - // enabled - GadgetSliderSetEnabledImageTop( slider, winFindImage( "VSliderLargeEnabledTopEnd" ) ); - GadgetSliderSetEnabledImageBottom( slider, winFindImage( "VSliderLargeEnabledBottomEnd" ) ); - GadgetSliderSetEnabledImageCenter( slider, winFindImage( "VSliderLargeEnabledRepeatingCenter" ) ); - GadgetSliderSetEnabledImageSmallCenter( slider, winFindImage( "VSliderLargeEnabledSmallRepeatingCenter" ) ); - GadgetSliderSetEnabledThumbImage( slider, winFindImage( "VSliderLargeThumbEnabled" ) ); - GadgetSliderSetEnabledSelectedThumbImage( slider, winFindImage( "VSliderLargeThumbEnabled" ) ); - - // disabled - GadgetSliderSetDisabledImageTop( slider, winFindImage( "VSliderLargeDisabledTopEnd" ) ); - GadgetSliderSetDisabledImageBottom( slider, winFindImage( "VSliderLargeDisabledBottomEnd" ) ); - GadgetSliderSetDisabledImageCenter( slider, winFindImage( "VSliderLargeDisabledRepeatingCenter" ) ); - GadgetSliderSetDisabledImageSmallCenter( slider, winFindImage( "VSliderLargeDisabledSmallRepeatingCenter" ) ); - GadgetSliderSetDisabledThumbImage( slider, winFindImage( "VSliderLargeThumbDisabled" ) ); - GadgetSliderSetDisabledSelectedThumbImage( slider, winFindImage( "VSliderLargeThumbDisabled" ) ); - - // hilite - GadgetSliderSetHiliteImageTop( slider, winFindImage( "VSliderLargeHiliteTopEnd" ) ); - GadgetSliderSetHiliteImageBottom( slider, winFindImage( "VSliderLargeHiliteBottomEnd" ) ); - GadgetSliderSetHiliteImageCenter( slider, winFindImage( "VSliderLargeHiliteRepeatingCenter" ) ); - GadgetSliderSetHiliteImageSmallCenter( slider, winFindImage( "VSliderLargeHiliteSmallRepeatingCenter" ) ); - GadgetSliderSetHiliteThumbImage( slider, winFindImage( "VSliderLargeThumbHilite" ) ); - GadgetSliderSetHiliteSelectedThumbImage( slider, winFindImage( "VSliderLargeThumbHilite" ) ); - - // up button ------------------------------------------------------------ - - // enabled - GadgetButtonSetEnabledImage( upButton, winFindImage( "VSliderLargeUpButtonEnabled" ) ); - GadgetButtonSetEnabledSelectedImage( upButton, winFindImage( "VSliderLargeUpButtonEnabled" ) ); - - // disabled - GadgetButtonSetDisabledImage( upButton, winFindImage( "VSliderLargeUpButtonDisabled" ) ); - GadgetButtonSetDisabledSelectedImage( upButton, winFindImage( "VSliderLargeUpButtonDisabled" ) ); - - // hilite - GadgetButtonSetHiliteImage( upButton, winFindImage( "VSliderLargeUpButtonHilite" ) ); - GadgetButtonSetHiliteSelectedImage( upButton, winFindImage( "VSliderLargeUpButtonHiliteSelected" ) ); - - // down button ---------------------------------------------------------- - - // enabled - GadgetButtonSetEnabledImage( downButton, winFindImage( "VSliderLargeDownButtonEnabled" ) ); - GadgetButtonSetEnabledSelectedImage( downButton, winFindImage( "VSliderLargeDownButtonEnabled" ) ); - - // disabled - GadgetButtonSetDisabledImage( downButton, winFindImage( "VSliderLargeDownButtonDisabled" ) ); - GadgetButtonSetDisabledSelectedImage( downButton, winFindImage( "VSliderLargeDownButtonDisabled" ) ); - - // hilite - GadgetButtonSetHiliteImage( downButton, winFindImage( "VSliderLargeDownButtonHilite" ) ); - GadgetButtonSetHiliteSelectedImage( downButton, winFindImage( "VSliderLargeDownButtonHiliteSelected" ) ); - - } - } - } - else if( BitIsSet( instData->getStyle(), GWS_PROGRESS_BAR ) ) - { - - // enabled - GadgetProgressBarSetEnabledColor( gadget, red ); - GadgetProgressBarSetEnabledBorderColor( gadget, lightRed ); - GadgetProgressBarSetEnabledImageLeft( gadget, winFindImage( "ProgressBarEnabledLeftEnd" ) ); - GadgetProgressBarSetEnabledImageRight( gadget, winFindImage( "ProgressBarEnabledRightEnd" ) ); - GadgetProgressBarSetEnabledImageCenter( gadget, winFindImage( "ProgressBarEnabledRepeatingCenter" ) ); - GadgetProgressBarSetEnabledImageSmallCenter( gadget, winFindImage( "ProgressBarEnabledSmallRepeatingCenter" ) ); - GadgetProgressBarSetEnabledBarColor( gadget, yellow ); - GadgetProgressBarSetEnabledBarBorderColor( gadget, white ); - GadgetProgressBarSetEnabledBarImageLeft( gadget, winFindImage( "ProgressBarEnabledBarLeftEnd" ) ); - GadgetProgressBarSetEnabledBarImageRight( gadget, winFindImage( "ProgressBarEnabledBarRightEnd" ) ); - GadgetProgressBarSetEnabledBarImageCenter( gadget, winFindImage( "ProgressBarEnabledBarRepeatingCenter" ) ); - GadgetProgressBarSetEnabledBarImageSmallCenter( gadget, winFindImage( "ProgressBarEnabledBarSmallRepeatingCenter" ) ); - - // disabled - GadgetProgressBarSetDisabledColor( gadget, darkGray ); - GadgetProgressBarSetDisabledBorderColor( gadget, lightGray ); - GadgetProgressBarSetDisabledImageLeft( gadget, winFindImage( "ProgressBarDisabledLeftEnd" ) ); - GadgetProgressBarSetDisabledImageRight( gadget, winFindImage( "ProgressBarDisabledRightEnd" ) ); - GadgetProgressBarSetDisabledImageCenter( gadget, winFindImage( "ProgressBarDisabledRepeatingCenter" ) ); - GadgetProgressBarSetDisabledImageSmallCenter( gadget, winFindImage( "ProgressBarDisabledSmallRepeatingCenter" ) ); - GadgetProgressBarSetDisabledBarColor( gadget, lightGray ); - GadgetProgressBarSetDisabledBarBorderColor( gadget, white ); - GadgetProgressBarSetDisabledBarImageLeft( gadget, winFindImage( "ProgressBarDisabledBarLeftEnd" ) ); - GadgetProgressBarSetDisabledBarImageRight( gadget, winFindImage( "ProgressBarDisabledBarRightEnd" ) ); - GadgetProgressBarSetDisabledBarImageCenter( gadget, winFindImage( "ProgressBarDisabledBarRepeatingCenter" ) ); - GadgetProgressBarSetDisabledBarImageSmallCenter( gadget, winFindImage( "ProgressBarDisabledBarSmallRepeatingCenter" ) ); - - // Hilite - GadgetProgressBarSetHiliteColor( gadget, green ); - GadgetProgressBarSetHiliteBorderColor( gadget, darkGreen ); - GadgetProgressBarSetHiliteImageLeft( gadget, winFindImage( "ProgressBarHiliteLeftEnd" ) ); - GadgetProgressBarSetHiliteImageRight( gadget, winFindImage( "ProgressBarHiliteRightEnd" ) ); - GadgetProgressBarSetHiliteImageCenter( gadget, winFindImage( "ProgressBarHiliteRepeatingCenter" ) ); - GadgetProgressBarSetHiliteImageSmallCenter( gadget, winFindImage( "ProgressBarHiliteSmallRepeatingCenter" ) ); - GadgetProgressBarSetHiliteBarColor( gadget, yellow ); - GadgetProgressBarSetHiliteBarBorderColor( gadget, white ); - GadgetProgressBarSetHiliteBarImageLeft( gadget, winFindImage( "ProgressBarHiliteBarLeftEnd" ) ); - GadgetProgressBarSetHiliteBarImageRight( gadget, winFindImage( "ProgressBarHiliteBarRightEnd" ) ); - GadgetProgressBarSetHiliteBarImageCenter( gadget, winFindImage( "ProgressBarHiliteBarRepeatingCenter" ) ); - GadgetProgressBarSetHiliteBarImageSmallCenter( gadget, winFindImage( "ProgressBarHiliteBarSmallRepeatingCenter" ) ); - - } - else if( BitIsSet( instData->getStyle(), GWS_STATIC_TEXT ) ) - { - - // enabled - GadgetStaticTextSetEnabledImage( gadget, winFindImage( "StaticTextEnabled" ) ); - GadgetStaticTextSetEnabledColor( gadget, red ); - GadgetStaticTextSetEnabledBorderColor( gadget, lightRed ); - - // disabled - GadgetStaticTextSetDisabledImage( gadget, winFindImage( "StaticTextDisabled" ) ); - GadgetStaticTextSetDisabledColor( gadget, darkGray ); - GadgetStaticTextSetDisabledBorderColor( gadget, lightGray ); - - // hilite - GadgetStaticTextSetHiliteImage( gadget, winFindImage( "StaticTextHilite" ) ); - GadgetStaticTextSetHiliteColor( gadget, darkGreen ); - GadgetStaticTextSetHiliteBorderColor( gadget, lightGreen ); - - // set default text colors for the gadget - gadget->winSetEnabledTextColors( enabledText, enabledTextBorder ); - gadget->winSetDisabledTextColors( disabledText, disabledTextBorder ); - gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder ); - gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder ); - - } - else if( BitIsSet( instData->getStyle(), GWS_ENTRY_FIELD ) ) - { - - // enabled - GadgetTextEntrySetEnabledImageLeft( gadget, winFindImage( "TextEntryEnabledLeftEnd" ) ); - GadgetTextEntrySetEnabledImageRight( gadget, winFindImage( "TextEntryEnabledRightEnd" ) ); - GadgetTextEntrySetEnabledImageCenter( gadget, winFindImage( "TextEntryEnabledRepeatingCenter" ) ); - GadgetTextEntrySetEnabledImageSmallCenter( gadget, winFindImage( "TextEntryEnabledSmallRepeatingCenter" ) ); - GadgetTextEntrySetEnabledColor( gadget, red ); - GadgetTextEntrySetEnabledBorderColor( gadget, lightRed ); - - // disabled - GadgetTextEntrySetDisabledImageLeft( gadget, winFindImage( "TextEntryDisabledLeftEnd" ) ); - GadgetTextEntrySetDisabledImageRight( gadget, winFindImage( "TextEntryDisabledRightEnd" ) ); - GadgetTextEntrySetDisabledImageCenter( gadget, winFindImage( "TextEntryDisabledRepeatingCenter" ) ); - GadgetTextEntrySetDisabledImageSmallCenter( gadget, winFindImage( "TextEntryDisabledSmallRepeatingCenter" ) ); - GadgetTextEntrySetDisabledColor( gadget, gray ); - GadgetTextEntrySetDisabledBorderColor( gadget, black ); - - // hilited - GadgetTextEntrySetHiliteImageLeft( gadget, winFindImage( "TextEntryHiliteLeftEnd" ) ); - GadgetTextEntrySetHiliteImageRight( gadget, winFindImage( "TextEntryHiliteRightEnd" ) ); - GadgetTextEntrySetHiliteImageCenter( gadget, winFindImage( "TextEntryHiliteRepeatingCenter" ) ); - GadgetTextEntrySetHiliteImageSmallCenter( gadget, winFindImage( "TextEntryHiliteSmallRepeatingCenter" ) ); - GadgetTextEntrySetHiliteColor( gadget, green ); - GadgetTextEntrySetHiliteBorderColor( gadget, darkGreen ); - - // set default text colors for the gadget - gadget->winSetEnabledTextColors( enabledText, enabledTextBorder ); - gadget->winSetDisabledTextColors( disabledText, disabledTextBorder ); - gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder ); - gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder ); - - } - -} - -//------------------------------------------------------------------------------------------------- -/** Given a text label, retreive the real localized text associated - * with that label */ -//------------------------------------------------------------------------------------------------- -UnicodeString GameWindowManager::winTextLabelToText( AsciiString label ) -{ - - // sanity - if( label.isEmpty() ) - return UnicodeString::TheEmptyString; - - /// @todo we need to write the string manager here, this is TEMPORARY!!! - UnicodeString tmp; - tmp.translate(label); - return tmp; - -} - -//------------------------------------------------------------------------------------------------- -/** find the top window at the given coordinates */ -//------------------------------------------------------------------------------------------------- -GameWindow *GameWindowManager::getWindowUnderCursor( Int x, Int y, Bool ignoreEnabled ) -{ - if( m_mouseCaptor ) - { - // in what what window within the captured window are we? - return m_mouseCaptor->winPointInChild( x, y, ignoreEnabled ); - } - - if( m_grabWindow ) - { - // in what what window within the grabbed window are we? - return m_grabWindow->winPointInChild( x, y, ignoreEnabled ); - } - - GameWindow *window = nullptr; - if( m_modalHead && m_modalHead->window ) - { - return m_modalHead->window->winPointInChild( x, y, ignoreEnabled ); - } - else - { - // search for top-level window which contains pointer - for( window = m_windowList; window; window = window->m_next ) - { - - if( BitIsSet( window->m_status, WIN_STATUS_ABOVE ) && - !BitIsSet( window->m_status, WIN_STATUS_HIDDEN ) && - x >= window->m_region.lo.x && - x <= window->m_region.hi.x && - y >= window->m_region.lo.y && - y <= window->m_region.hi.y) - { - if( BitIsSet( window->m_status, WIN_STATUS_ENABLED ) || ignoreEnabled ) - { - // determine which child window the mouse is in - window = window->winPointInChild( x, y, ignoreEnabled ); - break; // exit for - } - } - } - - // check !above, below and hidden - if( window == nullptr ) - { - for( window = m_windowList; window; window = window->m_next ) - { - if( !BitIsSet( window->m_status, WIN_STATUS_ABOVE | - WIN_STATUS_BELOW | - WIN_STATUS_HIDDEN ) && - x >= window->m_region.lo.x && - x <= window->m_region.hi.x && - y >= window->m_region.lo.y && - y <= window->m_region.hi.y) - { - if( BitIsSet( window->m_status, WIN_STATUS_ENABLED )|| ignoreEnabled) - { - // determine which child window the mouse is in - window = window->winPointInChild( x, y, ignoreEnabled ); - break; // exit for - } - } - } - } - - // check below and !hidden - if( window == nullptr ) - { - for( window = m_windowList; window; window = window->m_next ) - { - if( BitIsSet( window->m_status, WIN_STATUS_BELOW ) && - !BitIsSet( window->m_status, WIN_STATUS_HIDDEN ) && - x >= window->m_region.lo.x && - x <= window->m_region.hi.x && - y >= window->m_region.lo.y && - y <= window->m_region.hi.y) - { - if( BitIsSet( window->m_status, WIN_STATUS_ENABLED )|| ignoreEnabled) - { - // determine which child window the mouse is in - window = window->winPointInChild( x, y, ignoreEnabled ); - break; // exit for - } - } - } - } - } - - if( window ) - { - if( BitIsSet( window->m_status, WIN_STATUS_NO_INPUT )) - { - // this window does not accept input, discard - window = nullptr; - } - else if( ignoreEnabled && !( BitIsSet( window->m_status, WIN_STATUS_ENABLED ) )) - { - window = nullptr; - } - } - - return window; -} - -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -static WindowMsgHandledType testGrab( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - - switch( msg ) - { - - case GWM_LEFT_DOWN: return MSG_HANDLED; // use it - - } - - return MSG_IGNORED; - -} - -//------------------------------------------------------------------------------------------------- -/** Just for testing */ -//------------------------------------------------------------------------------------------------- -Bool GameWindowManager::initTestGUI() -{ - -// winCreateFromScript( "_ATest.wnd" ); - return TRUE; - -// UnsignedByte alpha = 200; - GameWindow *window; - UnsignedInt statusFlags = WIN_STATUS_ENABLED | WIN_STATUS_DRAGGABLE | WIN_STATUS_IMAGE; - WinInstanceData instData; - - // make some windows inside each other in the upper left - window = winCreate( nullptr, statusFlags, 0, 0, 100, 100, nullptr, nullptr ); - window->winSetInputFunc( testGrab ); - window->winSetEnabledColor( 0, winMakeColor( 255, 254, 255, 255 ) ); - window->winSetEnabledBorderColor( 0 , winMakeColor( 0, 0, 0, 255 ) ); - window = winCreate( window, statusFlags, 10, 10, 50, 50, nullptr, nullptr ); - window->winSetInputFunc( testGrab ); - window->winSetEnabledColor( 0, winMakeColor( 128, 128, 128, 255 ) ); - window->winSetEnabledBorderColor( 0 , winMakeColor( 0, 0, 0, 255 ) ); - - // make a push button - instData.init(); - BitSet( instData.m_style, GWS_PUSH_BUTTON | GWS_MOUSE_TRACK ); - instData.m_textLabelString = "What Up?"; - window = gogoGadgetPushButton( nullptr, - WIN_STATUS_ENABLED | WIN_STATUS_IMAGE, - 200, 100, - 100, 30, - &instData, nullptr, TRUE ); - - // make a push button - instData.init(); - BitSet( instData.m_style, GWS_PUSH_BUTTON | GWS_MOUSE_TRACK ); - instData.m_textLabelString = "Enabled"; - window = gogoGadgetPushButton( nullptr, - WIN_STATUS_ENABLED, - 330, 100, - 100, 30, - &instData, nullptr, TRUE ); - - // make a push button - instData.init(); - BitSet( instData.m_style, GWS_PUSH_BUTTON | GWS_MOUSE_TRACK ); - instData.m_textLabelString = "Disabled"; - window = gogoGadgetPushButton( nullptr, - 0, - 450, 100, - 100, 30, - &instData, nullptr, TRUE ); - - // make a check box - instData.init(); - instData.m_style = GWS_CHECK_BOX | GWS_MOUSE_TRACK; - instData.m_textLabelString = "Check"; - window = gogoGadgetCheckbox( nullptr, - WIN_STATUS_ENABLED | - WIN_STATUS_IMAGE, - 200, 150, - 100, 30, - &instData, nullptr, TRUE ); - - // make a check box - instData.init(); - instData.m_style = GWS_CHECK_BOX | GWS_MOUSE_TRACK; - instData.m_textLabelString = "Check"; - window = gogoGadgetCheckbox( nullptr, - WIN_STATUS_ENABLED, - 330, 150, - 100, 30, - &instData, nullptr, TRUE ); - - // make window to hold radio buttons - window = winCreate( nullptr, WIN_STATUS_ENABLED | WIN_STATUS_DRAGGABLE, - 200, 200, 250, 45, nullptr ); - window->winSetInputFunc( testGrab ); - window->winSetEnabledColor( 0, winMakeColor( 50, 50, 50, 200 ) ); - window->winSetEnabledBorderColor( 0, winMakeColor( 254, 254, 254, 255 ) ); - - // make a radio button - GameWindow *radio; - RadioButtonData rData; - instData.init(); - instData.m_style = GWS_RADIO_BUTTON | GWS_MOUSE_TRACK; - instData.m_textLabelString = "Mama Said!"; - rData.group = 1; - radio = gogoGadgetRadioButton( window, - WIN_STATUS_ENABLED | WIN_STATUS_IMAGE, - 10, 10, - 100, 30, - &instData, - &rData, nullptr, TRUE ); - - // make a radio button - instData.init(); - instData.m_style = GWS_RADIO_BUTTON | GWS_MOUSE_TRACK; - instData.m_textLabelString = "On the Run"; - radio = gogoGadgetRadioButton( window, - WIN_STATUS_ENABLED, - 130, 10, - 100, 30, - &instData, - &rData, nullptr, TRUE ); - GadgetRadioSetEnabledColor( radio, GameMakeColor( 0, 0, 255, 255 ) ); - GadgetRadioSetEnabledBorderColor( radio, GameMakeColor( 0, 0, 255, 255 ) ); - - // make a listbox - ListboxData listData; - memset( &listData, 0, sizeof( ListboxData ) ); - listData.listLength = 8; - listData.autoScroll = 1; - listData.scrollIfAtEnd = FALSE; - listData.autoPurge = 1; - listData.scrollBar = 1; - listData.multiSelect = 1; - listData.forceSelect = 0; - listData.columns = 1; - listData.columnWidth = nullptr; - instData.init(); - instData.m_style = GWS_SCROLL_LISTBOX | GWS_MOUSE_TRACK; - window = gogoGadgetListBox( nullptr, - WIN_STATUS_ENABLED, - 200, 250, - 100, 100, - &instData, - &listData, nullptr, TRUE ); - GadgetListBoxAddEntryText( window, L"Listbox text", - winMakeColor( 255, 255, 255, 255 ), -1, 0 ); - GadgetListBoxAddEntryText( window, L"More text", - winMakeColor( 105, 105, 255, 255 ), -1, 0 ); - GadgetListBoxAddEntryText( window, L"Nothing", - winMakeColor( 105, 105, 255, 255 ), -1, 0 ); - GadgetListBoxAddEntryText( window, L"Seasons", - winMakeColor( 105, 205, 255, 255 ), -1, 0 ); - GadgetListBoxAddEntryText( window, L"Misery", - winMakeColor( 235, 105, 255, 255 ), -1, 0 ); - GadgetListBoxAddEntryText( window, L"Natural", - winMakeColor( 105, 205, 45, 255 ), -1, 0 ); - window->winSetFont( TheFontLibrary->getFont( "Times New Roman", 12, FALSE ) ); - - // make a listbox - memset( &listData, 0, sizeof( ListboxData ) ); - listData.listLength = 8; - listData.autoScroll = 1; - listData.scrollIfAtEnd = FALSE; - listData.autoPurge = 1; - listData.scrollBar = 1; - listData.multiSelect = 0; - listData.forceSelect = 0; - listData.columns = 1; - listData.columnWidth = nullptr; - instData.init(); - instData.m_style = GWS_SCROLL_LISTBOX | GWS_MOUSE_TRACK; - window = gogoGadgetListBox( nullptr, - WIN_STATUS_ENABLED | WIN_STATUS_IMAGE, - 75, 250, - 100, 100, - &instData, - &listData, nullptr, TRUE ); - GadgetListBoxAddEntryText( window, L"Listbox text", - winMakeColor( 255, 255, 255, 255 ), -1, -1 ); - GadgetListBoxAddEntryText( window, L"More text", - winMakeColor( 105, 105, 255, 255 ), -1, -1 ); - GadgetListBoxAddEntryText( window, L"Nothing", - winMakeColor( 105, 105, 255, 255 ), -1, -1 ); - GadgetListBoxAddEntryText( window, L"Seasons", - winMakeColor( 105, 205, 255, 255 ), -1, -1 ); - GadgetListBoxAddEntryText( window, L"Misery", - winMakeColor( 235, 105, 255, 255 ), -1, -1 ); - GadgetListBoxAddEntryText( window, L"Natural", - winMakeColor( 105, 205, 45, 255 ), -1, -1 ); - - // make a vert slider - SliderData sliderData; - memset( &sliderData, 0, sizeof( sliderData ) ); - sliderData.maxVal = 100; - sliderData.minVal = 0; - sliderData.numTicks = 100; - sliderData.position = 0; - instData.init(); - instData.m_style = GWS_VERT_SLIDER | GWS_MOUSE_TRACK; - window = gogoGadgetSlider( nullptr, - WIN_STATUS_ENABLED, - 360, 250, - 11, 100, - &instData, - &sliderData, nullptr, TRUE ); - - // make a vert slider - memset( &sliderData, 0, sizeof( sliderData ) ); - sliderData.maxVal = 100; - sliderData.minVal = 0; - sliderData.numTicks = 100; - sliderData.position = 0; - instData.init(); - instData.m_style = GWS_VERT_SLIDER | GWS_MOUSE_TRACK; - window = gogoGadgetSlider( nullptr, - WIN_STATUS_ENABLED | WIN_STATUS_IMAGE, - 400, 250, - 11, 100, - &instData, - &sliderData, nullptr, TRUE ); - - // make a horizontal slider - memset( &sliderData, 0, sizeof( sliderData ) ); - sliderData.maxVal = 100; - sliderData.minVal = 0; - sliderData.numTicks = 100; - sliderData.position = 0; - instData.init(); - instData.m_style = GWS_HORZ_SLIDER | GWS_MOUSE_TRACK; - window = gogoGadgetSlider( nullptr, - WIN_STATUS_ENABLED, - 200, 400, - 200, 11, - &instData, - &sliderData, nullptr, TRUE ); - - // make a horizontal slider - memset( &sliderData, 0, sizeof( sliderData ) ); - sliderData.maxVal = 100; - sliderData.minVal = 0; - sliderData.numTicks = 100; - sliderData.position = 0; - instData.init(); - instData.m_style = GWS_HORZ_SLIDER | GWS_MOUSE_TRACK; - window = gogoGadgetSlider( nullptr, - WIN_STATUS_ENABLED | WIN_STATUS_IMAGE, - 200, 420, - 200, 11, - &instData, - &sliderData, nullptr, TRUE ); - - // make a progress bar - instData.init(); - instData.m_style = GWS_PROGRESS_BAR | GWS_MOUSE_TRACK; - window = gogoGadgetProgressBar( nullptr, - WIN_STATUS_ENABLED, - 200, 450, - 250, 15, - &instData, nullptr, TRUE ); - - // make a progress bar - instData.init(); - instData.m_style = GWS_PROGRESS_BAR | GWS_MOUSE_TRACK; - window = gogoGadgetProgressBar( nullptr, - WIN_STATUS_ENABLED | WIN_STATUS_IMAGE, - 200, 470, - 250, 15, - &instData, nullptr, TRUE ); - - // make some static text - TextData textData; - textData.centered = 1; - instData.init(); - instData.m_style = GWS_STATIC_TEXT | GWS_MOUSE_TRACK; - instData.m_textLabelString = "Centered Static Text"; - window = gogoGadgetStaticText( nullptr, - WIN_STATUS_ENABLED, - 200, 490, - 300, 25, - &instData, - &textData, nullptr, TRUE ); - - // make some static text - textData.centered = 0; - instData.init(); - instData.m_style = GWS_STATIC_TEXT | GWS_MOUSE_TRACK; - instData.m_textLabelString = "Not Centered Static Text"; - window = gogoGadgetStaticText( nullptr, - WIN_STATUS_ENABLED | WIN_STATUS_IMAGE, - 200, 520, - 300, 25, - &instData, - &textData, nullptr, TRUE ); - window->winSetEnabledTextColors( winMakeColor( 128, 128, 255, 255 ), - winMakeColor( 255, 255, 255, 255 ) ); - - // make some entry text - EntryData entryData; - memset( &entryData, 0, sizeof( entryData ) ); - entryData.maxTextLen = 30; - instData.init(); - instData.m_style = GWS_ENTRY_FIELD | GWS_MOUSE_TRACK; - instData.m_textLabelString = "Entry"; - window = gogoGadgetTextEntry( nullptr, - WIN_STATUS_ENABLED, - 450, 270, - 400, 30, - &instData, - &entryData, nullptr, TRUE ); - - // make some entry text - memset( &entryData, 0, sizeof( entryData ) ); - entryData.maxTextLen = 30; - instData.init(); - instData.m_style = GWS_ENTRY_FIELD | GWS_MOUSE_TRACK; - instData.m_textLabelString = "Entry"; - window = gogoGadgetTextEntry( nullptr, - WIN_STATUS_ENABLED | WIN_STATUS_IMAGE, - 450, 310, - 400, 30, - &instData, - &entryData, nullptr, TRUE ); - - return TRUE; - -} - - -void GameWindowManager::winNextTab( GameWindow *window ) -{ - if(m_tabList.empty()|| m_modalHead) - return; - - GameWindowList::iterator it = m_tabList.begin(); - while( it != m_tabList.end()) - { - if(*it == window) - { - it++; - break; - } - it++; - } - if(it != m_tabList.end()) - winSetFocus(*it); - else - { - winSetFocus(*m_tabList.begin()); - } - winSetLoneWindow(nullptr); -} - -void GameWindowManager::winPrevTab( GameWindow *window ) -{ - if(m_tabList.empty() || m_modalHead) - return; - - GameWindowList::reverse_iterator it = m_tabList.rbegin(); - while( it != m_tabList.rend()) - { - if(*it == window) - { - it++; - break; - } - it++; - } - if(it != m_tabList.rend()) - winSetFocus(*it); - else - { - winSetFocus(*m_tabList.rbegin()); - } - winSetLoneWindow(nullptr); -} - -void GameWindowManager::registerTabList( GameWindowList tabList ) -{ - m_tabList.clear(); - m_tabList = tabList; -} - -void GameWindowManager::clearTabList() -{ - m_tabList.clear(); -} - - -GameWindow *GameWindowManagerDummy::winGetWindowFromId(GameWindow *window, Int id) -{ - window = GameWindowManager::winGetWindowFromId(window, id); - if (window != nullptr) - return window; - - // Just return any window, callers expect this to be non-null - return m_windowList; -} - -WindowMsgHandledType DummyWindowSystem(GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2) -{ - return MSG_IGNORED; -} - -GameWindow *GameWindowManagerDummy::winCreateFromScript(AsciiString filenameString, WindowLayoutInfo *info) -{ - WindowLayoutInfo scriptInfo; - GameWindow* dummyWindow = winCreate(nullptr, 0, 0, 0, 100, 100, DummyWindowSystem, nullptr); - scriptInfo.windows.push_back(dummyWindow); - if (info) - *info = scriptInfo; - return dummyWindow; -} - -GameWindowDummy::~GameWindowDummy() -{ -} diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp deleted file mode 100644 index a3a9ffdae41..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp +++ /dev/null @@ -1,2881 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** 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 3 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, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: GameWindowManagerScript.cpp ////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: GameWindowManagerScript.cpp -// -// Created: Colin Day, June 2001 -// Dean Iverson, May 1998 -// -// Desc: Reading window definition files from disk for the window manager -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -// USER INCLUDES ////////////////////////////////////////////////////////////// -#include "Lib/BaseType.h" -#include "Common/Debug.h" -#include "Common/file.h" -#include "Common/FileSystem.h" -#include "Common/GameMemory.h" -#include "Common/NameKeyGenerator.h" -#include "Common/FunctionLexicon.h" -#include "GameClient/Display.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GameWindowGlobal.h" -#include "GameClient/GadgetStaticText.h" -#include "GameClient/GadgetTabControl.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameClient/GadgetPushButton.h" -#include "GameClient/GadgetRadioButton.h" -#include "GameClient/GadgetCheckBox.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetComboBox.h" -#include "GameClient/GadgetSlider.h" -#include "GameClient/GameText.h" -#include "GameClient/HeaderTemplate.h" - - - -// DEFINES //////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// PRIVATE TYPES ////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -enum -{ - WIN_BUFFER_LENGTH = 2048, - WIN_STACK_DEPTH = 10, -}; - -//------------------------------------------------------------------------------------------------- -/** Layout parse structure ... these data items apply to the window file itself, - * they are not associated with any window, but rather just a block of data in - * every file */ -//------------------------------------------------------------------------------------------------- -struct LayoutScriptParse -{ - - const char *name; - Bool (*parse)( const char *token, char *buffer, UnsignedInt version, WindowLayoutInfo *info ); - -}; - -// GameWindowParse ------------------------------------------------------------ -/** used to match database fields to parsing functions */ -//----------------------------------------------------------------------------- -struct GameWindowParse -{ - - const char *name; - Bool (*parse)( const char *token, WinInstanceData *, char *, void * ); - -}; - -/////////////////////////////////////////////////////////////////////////////// -// PRIVATE DATA /////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -// window methods and their string representations -static GameWinSystemFunc systemFunc = nullptr; -static GameWinInputFunc inputFunc = nullptr; -static GameWinTooltipFunc tooltipFunc = nullptr; -static GameWinDrawFunc drawFunc = nullptr; -static AsciiString theSystemString; -static AsciiString theInputString; -static AsciiString theTooltipString; -static AsciiString theDrawString; - -// default visual properties -static Color defEnabledColor = 0; -static Color defDisabledColor = 0; -static Color defBackgroundColor = 0; -static Color defHiliteColor = 0; -static Color defSelectedColor = 0; -static Color defTextColor = 0; -static GameFont *defFont = nullptr; - -// -// These strings must be in the same order as they are in their definitions -// (see WIN_STATUS_* enums and GWS_* enums). -// -const char *const WindowStatusNames[] = { "ACTIVE", "TOGGLE", "DRAGABLE", "ENABLED", "HIDDEN", - "ABOVE", "BELOW", "IMAGE", "TABSTOP", "NOINPUT", - "NOFOCUS", "DESTROYED", "BORDER", - "SMOOTH_TEXT", "ONE_LINE", "NO_FLUSH", "SEE_THRU", - "RIGHT_CLICK", "WRAP_CENTERED", "CHECK_LIKE","HOTKEY_TEXT", - "USE_OVERLAY_STATES", "NOT_READY", "FLASHING", "ALWAYS_COLOR", - nullptr }; - -const char *const WindowStyleNames[] = { "PUSHBUTTON", "RADIOBUTTON", "CHECKBOX", - "VERTSLIDER", "HORZSLIDER", "SCROLLLISTBOX", - "ENTRYFIELD", "STATICTEXT", "PROGRESSBAR", - "USER", "MOUSETRACK", "ANIMATED", - "TABSTOP", "TABCONTROL", "TABPANE", - "COMBOBOX", - nullptr }; - -// Implement a stack to keep track of parent/child nested window descriptions. -static GameWindow *windowStack[ WIN_STACK_DEPTH ]; -static GameWindow **stackPtr; - -// for parsing -static const char *seps = " =;\n\r\t"; -WinDrawData enabledDropDownButtonDrawData[ MAX_DRAW_DATA ]; ///< for combo boxes -WinDrawData disabledDropDownButtonDrawData[ MAX_DRAW_DATA ]; ///< for combo boxes -WinDrawData hiliteDropDownButtonDrawData[ MAX_DRAW_DATA ]; ///< for combo boxes - -WinDrawData enabledEditBoxDrawData[ MAX_DRAW_DATA ]; ///< for combo boxes -WinDrawData disabledEditBoxDrawData[ MAX_DRAW_DATA ]; ///< for combo boxes -WinDrawData hiliteEditBoxDrawData[ MAX_DRAW_DATA ]; ///< for combo boxes - -WinDrawData enabledListBoxDrawData[ MAX_DRAW_DATA ]; ///< for combo boxes -WinDrawData disabledListBoxDrawData[ MAX_DRAW_DATA ]; ///< for combo boxes -WinDrawData hiliteListBoxDrawData[ MAX_DRAW_DATA ]; ///< for combo boxes - -WinDrawData enabledUpButtonDrawData[ MAX_DRAW_DATA ]; ///< for list boxes and combo boxes -WinDrawData disabledUpButtonDrawData[ MAX_DRAW_DATA ]; ///< for list boxes and combo boxes -WinDrawData hiliteUpButtonDrawData[ MAX_DRAW_DATA ]; ///< for list boxes and combo boxes -WinDrawData enabledDownButtonDrawData[ MAX_DRAW_DATA ]; ///< for list boxes and combo boxes -WinDrawData disabledDownButtonDrawData[ MAX_DRAW_DATA ]; ///< for list boxes and combo boxes -WinDrawData hiliteDownButtonDrawData[ MAX_DRAW_DATA ]; ///< for list boxes and combo boxes -WinDrawData enabledSliderDrawData[ MAX_DRAW_DATA ]; ///< for list boxes and combo boxes -WinDrawData disabledSliderDrawData[ MAX_DRAW_DATA ]; ///< for list boxes and combo boxes -WinDrawData hiliteSliderDrawData[ MAX_DRAW_DATA ]; ///< for list boxes and combo boxes -WinDrawData enabledSliderThumbDrawData[ MAX_DRAW_DATA ]; ///< for sliders and list boxes and combo boxes -WinDrawData disabledSliderThumbDrawData[ MAX_DRAW_DATA ]; ///< for sliders and list boxes and combo boxes -WinDrawData hiliteSliderThumbDrawData[ MAX_DRAW_DATA ]; ///< for sliders and list boxes and combo boxes - -// PUBLIC DATA //////////////////////////////////////////////////////////////// - -// PRIVATE PROTOTYPES ///////////////////////////////////////////////////////// -static GameWindow *parseWindow( File *inFile, char *buffer ); - -/////////////////////////////////////////////////////////////////////////////// -// PRIVATE FUNCTIONS ////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -// parseBitFlag =============================================================== -/** Parse one of the "flags" referred to below in the header comment - * for ParseBitString(). Sets the appropriate bit in the 'bits' arg, - * if successful. Returns TRUE on success, else FALSE. */ -//============================================================================= -static Bool parseBitFlag( const char *flagString, UnsignedInt *bits, - ConstCharPtrArray flagList ) -{ - ConstCharPtrArray c; - int i; - - for( i = 0, c = flagList; *c; i++, c++ ) - { - - if( stricmp( *c, flagString ) == 0 ) - { - *bits |= (1 << i); - return TRUE; - } - - } - - return FALSE; - -} - -// parseBitString ============================================================= -/** Given a character string of the form 'A+B+C+D', parse the - * flags separated by the '+' symbols into a bitfield stored in the 'bits' - * argument. - * Note that this routine does not clear any bits, only sets them. */ -//============================================================================= -static void parseBitString( const char *inBuffer, UnsignedInt *bits, ConstCharPtrArray flagList ) -{ - char buffer[256]; - char *tok; - - // do not modify the inBuffer argument - strlcpy(buffer, inBuffer, ARRAY_SIZE(buffer)); - - if( strncmp( buffer, "NULL", 4 ) != 0 ) - { - for( tok = strtok( buffer, "+" ); tok; tok = strtok( nullptr, "+" ) ) - { - if ( !parseBitFlag( tok, bits, flagList ) ) - { - DEBUG_LOG(( "ParseBitString: Invalid flag '%s'.", tok )); - } - } - } - -} - -// readUntilSemicolon ========================================================= -//============================================================================= -static void readUntilSemicolon( File *fp, char *buffer, int maxBufLen ) -{ - int i = 0; - Bool start = TRUE; - - while( i < maxBufLen ) - { - - // get next character - fp->read(buffer + i, 1); - - // make all whitespace characters spaces - if( isspace( buffer[ i ] ) ) - { - - if( start == FALSE ) - buffer[ i++ ] = ' '; - - } - else - { - - start = FALSE; - - if( buffer[ i ] == ';' ) - { - - // found end of data chunk - buffer[ i ] = '\000'; - return; - - } - - i++; - } - - } - - DEBUG_LOG(( "ReadUntilSemicolon: ERROR - Read buffer overflow - input truncated." )); - - buffer[ maxBufLen - 1 ] = '\000'; - -} - -// scanBool =================================================================== -//============================================================================= -static Int scanBool( const char *source, Bool& val ) -{ - Int temp = 0; - Int ret = sscanf( source, "%d", &temp ); - val = (Bool)temp; - - return ret; -} - -// scanShort ================================================================== -//============================================================================= -static Int scanShort( const char *source, Short& val ) -{ - Int temp = 0; - Int ret = sscanf( source, "%d", &temp ); - val = (Short)temp; - - return ret; -} - -// scanInt ==================================================================== -//============================================================================= -static Int scanInt( const char *source, Int& val ) -{ - Int ret = sscanf( source, "%d", &val ); // not strictly necessary to wrap this, but it's more consistent - - return ret; -} - -// scanUnsignedInt ============================================================ -//============================================================================= -static Int scanUnsignedInt( const char *source, UnsignedInt& val ) -{ - Int ret = sscanf( source, "%d", &val ); // not strictly necessary to wrap this, but it's more consistent - - return ret; -} - -// resetWindowStack =========================================================== -//============================================================================= -static void resetWindowStack() -{ - - memset( windowStack, 0, sizeof( windowStack ) ); - stackPtr = windowStack; - -} - -// resetWindowDefaults ======================================================== -//============================================================================= -static void resetWindowDefaults() -{ - - defEnabledColor = 0; - defDisabledColor = 0; - defBackgroundColor = 0; - defHiliteColor = 0; - defSelectedColor = 0; - defTextColor = 0; - defFont = nullptr; - -} - -// peekWindow ================================================================= -//============================================================================= -static GameWindow *peekWindow() -{ - if (stackPtr == windowStack) - return nullptr; - - return *(stackPtr - 1); - -} - -// popWindow ================================================================== -//============================================================================= -static GameWindow *popWindow() -{ - - if( stackPtr == windowStack ) - return nullptr; - stackPtr--; - - return *stackPtr; - -} - -// pushWindow ================================================================= -//============================================================================= -static void pushWindow( GameWindow *window ) -{ - - if( stackPtr == &windowStack[ WIN_STACK_DEPTH - 1 ] ) - { - - DEBUG_LOG(( "pushWindow: Warning, stack overflow" )); - return; - - } - - *stackPtr++ = window; - -} - -// parseColor ================================================================= -/** Parse a color entry and store it in the value pointed to by the - * 'color' parm. */ -//============================================================================= -static Bool parseColor( Color *color, char *buffer ) -{ - char *c; - Byte red, green, blue; - - c = strtok( buffer, " \t\n\r" ); - red = atoi(c); - - c = strtok( nullptr, " \t\n\r" ); - green = atoi(c); - - c = strtok( nullptr, " \t\n\r" ); - blue = atoi(c); - - *color = TheWindowManager->winMakeColor( red, green, blue, 255 ); - - return TRUE; - -} - -// parseDefaultColor ========================================================== -/** Parse a default color entry and store it in the value pointed to by - * the 'color' parm. */ -//============================================================================= -static Bool parseDefaultColor( Color *color, File *inFile, char *buffer ) -{ - // eat '=' -// fscanf( inFile, "%*s" ); - AsciiString str; - inFile->scanString(str); - - // Read the rest of the color definition - readUntilSemicolon( inFile, buffer, WIN_BUFFER_LENGTH ); - - if (strcmp( buffer, "TRANSPARENT" ) == 0) - { - - *color = WIN_COLOR_UNDEFINED; - - } - else - parseColor( color, buffer ); - - return TRUE; - -} - -// parseDefaultFont =========================================================== -/** Parse the default font */ -//============================================================================= -static Bool parseDefaultFont( GameFont *font, File *inFile, char *buffer ) -{ - - // eat '=' -// fscanf( inFile, "%*s" ); - AsciiString str; - inFile->scanString(str); - - // Read the rest of the color definition - readUntilSemicolon( inFile, buffer, WIN_BUFFER_LENGTH ); - - /// @todo font parsing for window files work needed here -// *font = GetFont( buffer ); -// if( *font == nullptr ) -// return FALSE; - - return TRUE; - -} - -// parseTooltip =============================================================== -/** Parse the tooltip field */ -//============================================================================= -static Bool parseTooltip( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - UnicodeString tooltip; - tooltip.set(L"Need tooltip translation"); - /// @todo need to parse the tooltip in multibyte here - - instData->setTooltipText( tooltip ); - return TRUE; - -} - -// parseScreenRect ============================================================ -/** Parse the screen rect entry which tells us the position and size - * of window. Note we scale for the current resolution if needed - * and adjust to make the screen rect coords relative to any parent - * if present */ -//============================================================================= -static Bool parseScreenRect( const char *token, char *buffer, - Int *x, Int *y, Int *width, Int *height ) -{ - GameWindow *parent = peekWindow(); - IRegion2D screenRegion; - ICoord2D createRes; // creation resolution - const char *seps = " ,:=\n\r\t"; - char *c; - - c = strtok( nullptr, seps ); // UPPERLEFT token - c = strtok( nullptr, seps ); // x position - scanInt( c, screenRegion.lo.x ); - c = strtok( nullptr, seps ); // y posotion - scanInt( c, screenRegion.lo.y ); - - c = strtok( nullptr, seps ); // BOTTOMRIGHT token - c = strtok( nullptr, seps ); // x position - scanInt( c, screenRegion.hi.x ); - c = strtok( nullptr, seps ); // y posotion - scanInt( c, screenRegion.hi.y ); - - c = strtok( nullptr, seps ); // CREATIONRESOLUTION token - c = strtok( nullptr, seps ); // x creation resolution - scanInt( c, createRes.x ); - c = strtok( nullptr, seps ); // y creation resolution - scanInt( c, createRes.y ); - - // - // shrink or expand the screen region by the ratio of the current - // resolution divided by the creation resolution - // - Real xScale = (Real)TheDisplay->getWidth() / (Real)createRes.x; - Real yScale = (Real)TheDisplay->getHeight() / (Real)createRes.y; - screenRegion.lo.x = (Int)((Real)screenRegion.lo.x * xScale); - screenRegion.lo.y = (Int)((Real)screenRegion.lo.y * yScale); - screenRegion.hi.x = (Int)((Real)screenRegion.hi.x * xScale); - screenRegion.hi.y = (Int)((Real)screenRegion.hi.y * yScale); - - // - // given the screen region upper left compute the upper left that we - // will give this window, if we have a parent note that the position - // is relative to the parent client area, if no parent is present - // we're talking about the screen - // - if( parent ) - { - ICoord2D parentScreenPos; - - // get parent position on screen - parent->winGetScreenPosition( &parentScreenPos.x, &parentScreenPos.y ); - - // save x and y with parent position as relative (0,0) location - *x = screenRegion.lo.x - parentScreenPos.x; - *y = screenRegion.lo.y - parentScreenPos.y; - - } - else - { - - *x = screenRegion.lo.x; - *y = screenRegion.lo.y; - - } - - // save our width and height from the adjusted screen region locations - *width = screenRegion.hi.x - screenRegion.lo.x; - *height = screenRegion.hi.y - screenRegion.lo.y; - - return TRUE; - -} - -// parseImageOffset =========================================================== -/** Parse the image draw offset */ -//============================================================================= -static Bool parseImageOffset( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - char *c; - - c = strtok( buffer, " \t\n\r" ); - instData->m_imageOffset.x = atoi( c ); - - c = strtok( nullptr, " \t\n\r" ); - instData->m_imageOffset.y = atoi( c ); - - return TRUE; - -} - -// parseFont ================================================================== -/** Parse the font field */ -//============================================================================= -static Bool parseFont( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - char *c, *ptr; - const char *seps = " ,\n\r\t"; - const char *stringSeps = ":,\n\r\t\""; - char fontName[ 256 ]; - Int fontSize; - Int fontBold; - - // "NAME" - c = strtok( buffer, seps ); // label - // scan to the first " mark - ptr = buffer; - while( *ptr != '"' ) - ptr++; - ptr++; // skip the " - c = strtok( ptr, stringSeps ); // value - strlcpy(fontName, c, ARRAY_SIZE(fontName)); - - // "SIZE" - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, fontSize ); - - // "BOLD" - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, fontBold ); - - if( TheFontLibrary ) - { - GameFont *font = TheFontLibrary->getFont( AsciiString(fontName), fontSize, fontBold ); - if( font ) - instData->m_font = font; - } - - return TRUE; - -} - -// parseName ================================================================= -/** Parse the NAME field */ -//============================================================================= -static Bool parseName( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - char *c, *ptr; -// const char *seps = " ,\n\r\t"; - const char *stringSeps = "\""; - - // scan to the first " mark - ptr = buffer; - while( *ptr != '"' ) - ptr++; - ptr++; // skip the first " - c = strtok( ptr, stringSeps ); // name value - instData->m_decoratedNameString = c; - - // given the name assign a window ID from the - assert( TheNameKeyGenerator ); - if( TheNameKeyGenerator ) - instData->m_id = (Int)TheNameKeyGenerator->nameToKey( instData->m_decoratedNameString ); - - return TRUE; - -} - -// parseStatus ================================================================ -/** Parse the STATUS field */ -//============================================================================= -static Bool parseStatus( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - - instData->m_status = 0; - parseBitString( buffer, &instData->m_status, WindowStatusNames ); - - return TRUE; - -} - -// parseStyle ================================================================= -/** Parse the STYLE field */ -//============================================================================= -static Bool parseStyle( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - - instData->m_style = 0; - parseBitString( buffer, &instData->m_style, WindowStyleNames ); - - return TRUE; - -} - -// parseSystemCallback ======================================================== -/** Parse the system method callback for a window */ -//============================================================================= -static Bool parseSystemCallback( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - char *c, *ptr; -// const char *seps = " ,\n\r\t"; - const char *stringSeps = "\""; - - // scan to the first " mark - ptr = buffer; - while( *ptr != '"' ) - ptr++; - ptr++; // skip the first " - c = strtok( ptr, stringSeps ); // name value - - // save a pointer of the function address - DEBUG_ASSERTCRASH( TheNameKeyGenerator && TheFunctionLexicon, ("Invalid singletons") ); - theSystemString = c; - NameKeyType key = TheNameKeyGenerator->nameToKey( theSystemString ); - systemFunc = TheFunctionLexicon->gameWinSystemFunc( key ); - - return TRUE; - -} - -// parseInputCallback ========================================================= -/** Parse the Input method callback for a window */ -//============================================================================= -static Bool parseInputCallback( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - char *c, *ptr; -// const char *seps = " ,\n\r\t"; - const char *stringSeps = "\""; - - // scan to the first " mark - ptr = buffer; - while( *ptr != '"' ) - ptr++; - ptr++; // skip the first " - c = strtok( ptr, stringSeps ); // name value - - // save a pointer of the function address - DEBUG_ASSERTCRASH( TheNameKeyGenerator && TheFunctionLexicon, ("Invalid singletons") ); - theInputString = c; - NameKeyType key = TheNameKeyGenerator->nameToKey( theInputString ); - inputFunc = TheFunctionLexicon->gameWinInputFunc( key ); - - return TRUE; - -} - -// parseTooltipCallback ======================================================= -/** Parse the Tooltip method callback for a window */ -//============================================================================= -static Bool parseTooltipCallback( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - char *c, *ptr; -// const char *seps = " ,\n\r\t"; - const char *stringSeps = "\""; - - // scan to the first " mark - ptr = buffer; - while( *ptr != '"' ) - ptr++; - ptr++; // skip the first " - c = strtok( ptr, stringSeps ); // name value - - // save a pointer of the function address - DEBUG_ASSERTCRASH( TheNameKeyGenerator && TheFunctionLexicon, ("Invalid singletons") ); - theTooltipString = c; - NameKeyType key = TheNameKeyGenerator->nameToKey( theTooltipString ); - tooltipFunc = TheFunctionLexicon->gameWinTooltipFunc( key ); - - return TRUE; - -} - -// parseDrawCallback ========================================================== -/** Parse the Draw method callback for a window */ -//============================================================================= -static Bool parseDrawCallback( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - char *c, *ptr; -// const char *seps = " ,\n\r\t"; - const char *stringSeps = "\""; - - // scan to the first " mark - ptr = buffer; - while( *ptr != '"' ) - ptr++; - ptr++; // skip the first " - c = strtok( ptr, stringSeps ); // name value - - // save a pointer of the function address - DEBUG_ASSERTCRASH( TheNameKeyGenerator && TheFunctionLexicon, ("Invalid singletons") ); - theDrawString = c; - NameKeyType key = TheNameKeyGenerator->nameToKey( theDrawString ); - drawFunc = TheFunctionLexicon->gameWinDrawFunc( key ); - - return TRUE; - -} - -// parseHeaderTemplate ========================================================== -/** Parse the Draw method callback for a window */ -//============================================================================= -static Bool parseHeaderTemplate( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - char *c, *ptr; -// const char *seps = " ,\n\r\t"; - const char *stringSeps = "\""; - - // scan to the first " mark - ptr = buffer; - while( *ptr != '"' ) - ptr++; - ptr++; // skip the first " - c = strtok( ptr, stringSeps ); // name value - - // save a pointer of the function address - DEBUG_ASSERTCRASH( TheNameKeyGenerator && TheFunctionLexicon, ("Invalid singletons") ); - - instData->m_headerTemplateName = c; - - return TRUE; - -} - -// parseListboxData =========================================================== -/** Parse listbox data entry */ -//============================================================================= -static Bool parseListboxData( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - ListboxData *listData = (ListboxData *)data; - char *c; - const char *seps = " :,\n\r\t"; - - // "LENGTH" - c = strtok( buffer, seps ); // label - c = strtok( nullptr, seps ); - scanShort( c, listData->listLength ); - - // "AUTOSCROLL" - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanBool( c, listData->autoScroll ); - - // "SCROLLIFATEND" (optional) - c = strtok( nullptr, seps ); // label - if ( stricmp(c, "ScrollIfAtEnd") == 0 ) - { - c = strtok( nullptr, seps ); // value - scanBool( c, listData->scrollIfAtEnd ); - c = strtok( nullptr, seps ); // label - } - else - { - listData->scrollIfAtEnd = FALSE; - } - - // "AUTOPURGE" - c = strtok( nullptr, seps ); // value - scanBool( c, listData->autoPurge ); - - // "SCROLLBAR" - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanBool( c, listData->scrollBar ); - - // "MULTISELECT" - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanBool( c, listData->multiSelect ); - - // "COLUMNS" - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanShort( c, listData->columns ); - if(listData->columns > 1) - { - listData->columnWidthPercentage = NEW Int[listData->columns]; - for(Int i = 0; i < listData->columns; i++ ) - { - // "COLUMNS" - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, listData->columnWidthPercentage[i] ); - } - } - else - listData->columnWidthPercentage = nullptr; - listData->columnWidth = nullptr; - // "FORCESELECT" - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanBool( c, listData->forceSelect ); - - - // " - return TRUE; - -} - -// parseComboBoxData =========================================================== -/** Parse Combo Box data entry */ -//============================================================================= -static Bool parseComboBoxData( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - ComboBoxData *comboData = (ComboBoxData *)data; - char *c; - const char *seps = " :,\n\r\t"; - - c = strtok( buffer, seps ); // label - c = strtok( nullptr, seps ); // value - scanBool( c, comboData->isEditable ); - - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, comboData->maxChars ); - - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, comboData->maxDisplay ); - - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanBool( c, comboData->asciiOnly ); - - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanBool( c, comboData->lettersAndNumbersOnly ); - - - return TRUE; -} - -// parseSliderData ============================================================ -/** Parse slider data entry */ -//============================================================================= -static Bool parseSliderData( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - SliderData *sliderData = (SliderData *)data; - char *c; - const char *seps = " :,\n\r\t"; - - // "MINVALUE" - c = strtok( buffer, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, sliderData->minVal ); - - // "MAXVALUE" - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, sliderData->maxVal ); - - return TRUE; - -} - -// parseRadioButtonData ======================================================= -/** Parse radio button data entry */ -//============================================================================= -static Bool parseRadioButtonData( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - RadioButtonData *radioData = (RadioButtonData *)data; - char *c; - const char *seps = " :,\n\r\t"; - - // "GROUP" - c = strtok( buffer, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, radioData->group ); - - return TRUE; - -} - - -// parseTooltipText =========================================================== -/** Parse the TOOLTIPTEXT field */ -//============================================================================= -static Bool parseTooltipText( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - char *ptr = buffer; - char *c; - const char *stringSeps = "\n\r\t\""; - - // scan to the first " mark - while( *ptr != '"' ) - ptr++; - ptr++; // skip the " - if(strlen( ptr ) == 1 ) - return TRUE; - c = strtok( ptr, stringSeps ); // value - if( strlen( c ) >= MAX_TEXT_LABEL ) - { - - DEBUG_LOG(( "TextTooltip label '%s' is too long, max is '%d'", c, MAX_TEXT_LABEL )); - assert( 0 ); - return FALSE; - - } - instData->m_tooltipString.set(c); - instData->setTooltipText(TheGameText->fetch(c)); - - - return TRUE; - -} - -// parseTooltipDelay ======================================================= -/** Parse the tooltip delay */ -//============================================================================= -static Bool parseTooltipDelay( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - //RadioButtonData *radioData = (RadioButtonData *)data; - char *c; - const char *seps = " :,\n\r\t"; - - // "getvalue" - c = strtok( buffer, seps ); // value - scanInt( c, instData->m_tooltipDelay ); - - return TRUE; - -} - - -// parseText ================================================================== -/** Parse the TEXT field */ -//============================================================================= -static Bool parseText( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - char *ptr = buffer; - char *c; - const char *stringSeps = "\n\r\t\""; - - // scan to the first " mark - while( *ptr != '"' ) - ptr++; - ptr++; // skip the " - c = strtok( ptr, stringSeps ); // value - if( strlen( c ) >= MAX_TEXT_LABEL ) - { - - DEBUG_LOG(( "Text label '%s' is too long, max is '%d'", c, MAX_TEXT_LABEL )); - assert( 0 ); - return FALSE; - - } - instData->m_textLabelString = c; - - - return TRUE; - -} - -// parseTextColor ============================================================= -/** Parse text color entries for enabled, disabled, and hilite with - * drop shadow colors */ -//============================================================================= -static Bool parseTextColor( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - char *c; - const char *seps = " :,\n\r\t"; - UnsignedInt r, g, b, a; - Int i, states = 3; - TextDrawData *textData; - Bool first = TRUE; - - - for( i = 0; i < states; i++ ) - { - - if( i == 0 ) - textData = &instData->m_enabledText; - else if( i == 1 ) - textData = &instData->m_disabledText; - else if( i == 2 ) - textData = &instData->m_hiliteText; - else - { - - DEBUG_LOG(( "Undefined state for text color" )); - assert( 0 ); - return FALSE; - - } - - // color - if( first == TRUE ) - c = strtok( buffer, seps ); // label - else - c = strtok( nullptr, seps ); // label - first = FALSE; - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, r ); - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, g ); - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, b ); - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, a ); - textData->color = GameMakeColor( r, g, b, a ); - - // border color - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, r ); - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, g ); - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, b ); - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, a ); - textData->borderColor = GameMakeColor( r, g, b, a ); - - } - - return TRUE; - -} - -// parseStaticTextData ======================================================== -/** Parse static text data entry */ -//============================================================================= -static Bool parseStaticTextData( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - TextData *textData = (TextData *)data; - char *c; - const char *seps = " :,\n\r\t"; - - // "CENTERED" - c = strtok( buffer, seps ); // label - c = strtok( nullptr, seps ); // value - scanBool( c, textData->centered ); - - // @todo: add these to GUIEdit options and output - // These are initialized here because any TextData constructor would never get called. - // The behavior with these defaults is the same as it was before these members were added. - textData->centeredVertically = TRUE; - textData->leftMargin = 7; - textData->topMargin = 7; - - return TRUE; - -} - -// parseTextEntryData ========================================================= -/** Parse text entry data entry */ -//============================================================================= -static Bool parseTextEntryData( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - EntryData *entryData = (EntryData *)data; - char *c; - const char *seps = " :,\n\r\t"; - - // "MAXLEN" - c = strtok( buffer, seps ); // label - c = strtok( nullptr, seps ); // value - scanShort( c, entryData->maxTextLen ); - - // "SECRETTEXT" - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanBool( c, entryData->secretText ); - - // "NUMERICALONLY" - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanBool( c, entryData->numericalOnly ); - - // "ALPHANUMERICALONLY" - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanBool( c, entryData->alphaNumericalOnly ); - - // "ASCIIONLY" - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanBool( c, entryData->aSCIIOnly ); - - return TRUE; - -} - -// parseTabControlData ========================================================= -/** Parse tab control data entry */ -//============================================================================= -static Bool parseTabControlData( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - TabControlData *tabControlData = (TabControlData *)data; - char *c; - const char *seps = " :,\n\r\t"; - - //TABORIENTATION - c = strtok( buffer, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, tabControlData->tabOrientation ); - - //TABEDGE - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, tabControlData->tabEdge ); - - //TABWIDTH - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, tabControlData->tabWidth ); - - //TABHEIGHT - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, tabControlData->tabHeight ); - - //TABCOUNT - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, tabControlData->tabCount ); - - //PANEBORDER - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, tabControlData->paneBorder ); - - //PANEDISABLED - Int entryCount = 0; - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanInt( c, entryCount ); - - for( Int paneIndex = 0; paneIndex < entryCount; paneIndex ++ ) - { - c = strtok( nullptr, seps ); // value - scanBool( c, tabControlData->subPaneDisabled[paneIndex] ); - } - - return TRUE; -} - -// parseDrawData ============================================================== -/** Parse set of draw data elements */ -//============================================================================= -static Bool parseDrawData( const char *token, WinInstanceData *instData, - char *buffer, void *data ) -{ - Int i; - UnsignedInt r, g, b, a; - WinDrawData *drawData; - Bool first = TRUE; - char *c; - const char *seps = " :,\n\r\t"; - - for( i = 0; i < MAX_DRAW_DATA; i++ ) - { - - // get the right draw data - if( strcmp( token, "ENABLEDDRAWDATA" ) == 0 ) - drawData = &instData->m_enabledDrawData[ i ]; - else if( strcmp( token, "DISABLEDDRAWDATA" ) == 0 ) - drawData = &instData->m_disabledDrawData[ i ]; - else if( strcmp( token, "HILITEDRAWDATA" ) == 0 ) - drawData = &instData->m_hiliteDrawData[ i ]; - else if( strcmp( token, "LISTBOXENABLEDUPBUTTONDRAWDATA" ) == 0 ) - drawData = &enabledUpButtonDrawData[ i ]; - else if( strcmp( token, "LISTBOXDISABLEDUPBUTTONDRAWDATA" ) == 0 ) - drawData = &disabledUpButtonDrawData[ i ]; - else if( strcmp( token, "LISTBOXHILITEUPBUTTONDRAWDATA" ) == 0 ) - drawData = &hiliteUpButtonDrawData[ i ]; - else if( strcmp( token, "LISTBOXENABLEDDOWNBUTTONDRAWDATA" ) == 0 ) - drawData = &enabledDownButtonDrawData[ i ]; - else if( strcmp( token, "LISTBOXDISABLEDDOWNBUTTONDRAWDATA" ) == 0 ) - drawData = &disabledDownButtonDrawData[ i ]; - else if( strcmp( token, "LISTBOXHILITEDOWNBUTTONDRAWDATA" ) == 0 ) - drawData = &hiliteDownButtonDrawData[ i ]; - else if( strcmp( token, "LISTBOXENABLEDSLIDERDRAWDATA" ) == 0 ) - drawData = &enabledSliderDrawData[ i ]; - else if( strcmp( token, "LISTBOXDISABLEDSLIDERDRAWDATA" ) == 0 ) - drawData = &disabledSliderDrawData[ i ]; - else if( strcmp( token, "LISTBOXHILITESLIDERDRAWDATA" ) == 0 ) - drawData = &hiliteSliderDrawData[ i ]; - else if( strcmp( token, "SLIDERTHUMBENABLEDDRAWDATA" ) == 0 ) - drawData = &enabledSliderThumbDrawData[ i ]; - else if( strcmp( token, "SLIDERTHUMBDISABLEDDRAWDATA" ) == 0 ) - drawData = &disabledSliderThumbDrawData[ i ]; - else if( strcmp( token, "SLIDERTHUMBHILITEDRAWDATA" ) == 0 ) - drawData = &hiliteSliderThumbDrawData[ i ]; - else if( strcmp( token, "COMBOBOXDROPDOWNBUTTONENABLEDDRAWDATA" ) == 0 ) - drawData = &enabledDropDownButtonDrawData[ i ]; - else if( strcmp( token, "COMBOBOXDROPDOWNBUTTONDISABLEDDRAWDATA" ) == 0 ) - drawData = &disabledDropDownButtonDrawData[ i ]; - else if( strcmp( token, "COMBOBOXDROPDOWNBUTTONHILITEDRAWDATA" ) == 0 ) - drawData = &hiliteDropDownButtonDrawData[ i ]; - else if( strcmp( token, "COMBOBOXEDITBOXENABLEDDRAWDATA" ) == 0 ) - drawData = &enabledEditBoxDrawData[ i ]; - else if( strcmp( token, "COMBOBOXEDITBOXDISABLEDDRAWDATA" ) == 0 ) - drawData = &disabledEditBoxDrawData[ i ]; - else if( strcmp( token, "COMBOBOXEDITBOXHILITEDRAWDATA" ) == 0 ) - drawData = &hiliteEditBoxDrawData[ i ]; - else if( strcmp( token, "COMBOBOXLISTBOXENABLEDDRAWDATA" ) == 0 ) - drawData = &enabledListBoxDrawData[ i ]; - else if( strcmp( token, "COMBOBOXLISTBOXDISABLEDDRAWDATA" ) == 0 ) - drawData = &disabledListBoxDrawData[ i ]; - else if( strcmp( token, "COMBOBOXLISTBOXHILITEDRAWDATA" ) == 0 ) - drawData = &hiliteListBoxDrawData[ i ]; - else - { - - DEBUG_LOG(( "ParseDrawData, undefined token '%s'", token )); - assert( 0 ); - return FALSE; - - } - - // IMAGE: X - if( first == TRUE ) - c = strtok( buffer, seps ); // label - else - c = strtok( nullptr, seps ); // label - first = FALSE; - - c = strtok( nullptr, seps ); // value - if( strcmp( c, "NoImage" ) != 0 ) - drawData->image = TheMappedImageCollection->findImageByName( AsciiString( c ) ); - else - drawData->image = nullptr; - // COLOR: R G B A - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, r ); - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, g ); - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, b ); - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, a ); - drawData->color = GameMakeColor( r, g, b, a ); - - // BORDERCOLOR: R G B A - c = strtok( nullptr, seps ); // label - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, r ); - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, g ); - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, b ); - c = strtok( nullptr, seps ); // value - scanUnsignedInt( c, a ); - drawData->borderColor = GameMakeColor( r, g, b, a ); - - } - - return TRUE; - -} - -// getDataTemplate ============================================================ -/** Given a window type style string return the address of a static - * gadget data type used for the generic data pointers in the - * GUI gadget controls */ -//============================================================================= -void *getDataTemplate( char *type ) -{ - static EntryData eData; - static SliderData sData; - static ListboxData lData; - static TextData tData; - static RadioButtonData rData; - static TabControlData tcData; - static ComboBoxData cData; - void *data; - - if( strcmp( type, "VERTSLIDER" ) == 0 || strcmp( type, "HORZSLIDER" ) == 0 ) - { - - memset( &sData, 0, sizeof( SliderData ) ); - data = &sData; - - } - else if( strcmp( type, "SCROLLLISTBOX" ) == 0 ) - { - - memset( &lData, 0, sizeof( ListboxData ) ); - data = &lData; - - } - else if( strcmp( type, "TABCONTROL" ) == 0 ) - { - memset( &tcData, 0, sizeof( TabControlData ) ); - data = &tcData; - } - else if( strcmp( type, "ENTRYFIELD" ) == 0 ) - { - - memset( &eData, 0, sizeof( EntryData ) ); - data = &eData; - - } - else if( strcmp( type, "STATICTEXT" ) == 0 ) - { - - memset( &tData, 0, sizeof( TextData ) ); - data = &tData; - - } - else if( strcmp( type, "RADIOBUTTON" ) == 0 ) - { - - memset( &rData, 0, sizeof( RadioButtonData ) ); - data = &rData; - } - else if( strcmp( type, "COMBOBOX" ) == 0 ) - { - - memset( &cData, 0, sizeof( ComboBoxData ) ); - data = &cData; - } - else - data = nullptr; - - return data; - -} - -// parseData ================================================================== -// -// Parse the data for gadgets. For sliders the data is in the format: -// -// -// For listboxes the data is formatted as: -// -// -// For Combo Boxes the data is formatted as: -// -// -// For entry fields the data is as follows: -// <1 = NumericalOnly, 2 = AlphaNumericOnly> -// -// For text the data is as follows: -// -// -// 1/2/2003: THIS FUNCTION IS NEVER REACHED; IT IS OBSOLETE -MDC -// -//============================================================================= -static Bool parseData( void **data, char *type, char *buffer ) -{ - char *c; - static EntryData eData; - static SliderData sData; - static ListboxData lData; - static TextData tData; - static RadioButtonData rData; - static ComboBoxData cData; - - if( strcmp( type, "VERTSLIDER" ) == 0 || strcmp( type, "HORZSLIDER" ) == 0 ) - { - - memset( &sData, 0, sizeof( SliderData ) ); - - c = strtok( buffer, " \t\n\r" ); - sData.minVal = atoi(c); - - c = strtok( nullptr, " \t\n\r" ); - sData.maxVal = atoi(c); - - *data = &sData; - - } - else if( strcmp( type, "SCROLLLISTBOX" ) == 0 ) - { - - memset( &lData, 0, sizeof( ListboxData ) ); - - c = strtok( buffer, " \t\n\r" ); - lData.listLength = atoi(c); - -// c = strtok( nullptr, " \t\n\r" ); -// lData.entryHeight = atoi(c); - - c = strtok( nullptr, " \t\n\r" ); - lData.autoScroll = atoi(c); - - c = strtok( nullptr, " \t\n\r" ); - lData.autoPurge = atoi(c); - - c = strtok( nullptr, " \t\n\r" ); - lData.scrollBar = atoi(c); - - c = strtok( nullptr, " \t\n\r" ); - lData.multiSelect = atoi(c); - - c = strtok( nullptr, " \t\n\r" ); - lData.forceSelect = atoi(c); - - *data = &lData; - - } - else if( strcmp( type, "ENTRYFIELD" ) == 0 ) - { - - memset( &eData, 0, sizeof( EntryData ) ); - - c = strtok( buffer, " \t\n\r" ); - eData.maxTextLen = atoi(c); - - c = strtok( nullptr, " \t\n\r" ); -// if (c) -// eData.entryWidth = atoi(c); -// else -// eData.entryWidth = -1; - - c = strtok( nullptr, " \t\n\r" ); - if (c) - { - eData.secretText = atoi(c); - - if( eData.secretText != FALSE ) - eData.secretText = TRUE; - } - else - eData.secretText = FALSE; - - c = strtok( nullptr, " \t\n\r" ); - if (c) - { - eData.numericalOnly = ( atoi(c) == 1 ); - eData.alphaNumericalOnly = ( atoi(c) == 2 ); - eData.aSCIIOnly = ( atoi(c) == 3 ); - } - else - { - eData.numericalOnly = FALSE; - eData.alphaNumericalOnly = FALSE; - eData.aSCIIOnly = FALSE; - } - *data = &eData; - - } - else if( strcmp( type, "STATICTEXT" ) == 0 ) - { - - c = strtok( buffer, " \t\n\r" ); - tData.centered = atoi(c); - - if( tData.centered != FALSE ) - tData.centered = TRUE; - - c = strtok( nullptr, " \t\n\r" ); - - /** @todo need to get a label from the translation manager, uncomment - the following line and remove the WideChar assignment when - we have it */ -// text = StringManagerFetch( c ); -// text = L"Need StrManager, Remove me!"; -// TheWindowManager->winStrcpy( tData.text, text ); - - *data = &tData; - - } - else if( strcmp( type, "RADIOBUTTON" ) == 0 ) - { - - c = strtok( buffer, " \t\n\r" ); - rData.group = atoi(c); -/// @todo Colin: Why was this here??? -// if( tData.centered != FALSE ) -// { -// tData.centered = TRUE; -// } - *data = &rData; - } - else - *data = nullptr; - - return TRUE; - -} - -// setWindowText ============================================================== -/** Set the default text for a window or gadget control */ -//============================================================================= -static void setWindowText( GameWindow *window, AsciiString textLabel ) -{ - - // sanity - if (textLabel.isEmpty()) - return; - - UnicodeString theText, entryText; - //Translate the text - theText = TheGameText->fetch( (char *)textLabel.str()); - // set the text in the window based on what it is - if( BitIsSet( window->winGetStyle(), GWS_PUSH_BUTTON ) ) - GadgetButtonSetText( window, theText ); - else if( BitIsSet( window->winGetStyle(), GWS_RADIO_BUTTON ) ) - GadgetRadioSetText( window, theText ); - else if( BitIsSet( window->winGetStyle(), GWS_CHECK_BOX ) ) - GadgetCheckBoxSetText( window, theText ); - else if( BitIsSet( window->winGetStyle(), GWS_STATIC_TEXT ) ) - GadgetStaticTextSetText( window, theText ); - else if( BitIsSet( window->winGetStyle(), GWS_ENTRY_FIELD ) ) - { - entryText.translate(textLabel); - GadgetTextEntrySetText( window, entryText ); - } - else - window->winSetText( theText ); - -} - -// createGadget =============================================================== -/** Create a gadget based on the 'type' parm */ -//============================================================================= -static GameWindow *createGadget( char *type, - GameWindow *parent, - Int status, - Int x, Int y, - Int width, Int height, - WinInstanceData *instData, - void *data ) -{ - GameWindow *window = nullptr; - - instData->m_owner = parent; - - if( strcmp( type, "PUSHBUTTON" ) == 0 ) - { - - instData->m_style |= GWS_PUSH_BUTTON; - window = TheWindowManager->gogoGadgetPushButton( parent, status, x, y, - width, height, - instData, - instData->m_font, FALSE ); - - } - else if( strcmp( type, "RADIOBUTTON" ) == 0 ) - { - RadioButtonData *rData = (RadioButtonData *)data; - char filename[ MAX_WINDOW_NAME_LEN ]; - char *c; - - // - // assign a screen identifier to the radio button based on the - // filename the radio button was saved in - // - - strlcpy(filename, instData->m_decoratedNameString.str(), ARRAY_SIZE(filename)); - c = strchr( filename, ':' ); - if( c ) - *c = 0; // terminate after filename (format is filename:gadgetname) - assert( TheNameKeyGenerator ); - if( TheNameKeyGenerator ) - rData->screen = (Int)(TheNameKeyGenerator->nameToKey( filename )); - - instData->m_style |= GWS_RADIO_BUTTON; - window = TheWindowManager->gogoGadgetRadioButton( parent, status, x, y, - width, height, - instData, rData, - instData->m_font, FALSE ); - - } - else if( strcmp( type, "CHECKBOX" ) == 0 ) - { - - instData->m_style |= GWS_CHECK_BOX; - window = TheWindowManager->gogoGadgetCheckbox( parent, status, x, y, - width, height, - instData, - instData->m_font, FALSE ); - - } - else if( strcmp( type, "TABCONTROL" ) == 0 ) - { - TabControlData *tcData = (TabControlData *)data; - instData->m_style |= GWS_TAB_CONTROL; - window = TheWindowManager->gogoGadgetTabControl( parent, status, x, y, - width, height, - instData, tcData, - instData->m_font, FALSE ); - } - else if( strcmp( type, "VERTSLIDER" ) == 0 ) - { - SliderData *sData = (SliderData *)data; - - instData->m_style |= GWS_VERT_SLIDER; - window = TheWindowManager->gogoGadgetSlider( parent, status, x, y, - width, height, - instData, sData, - instData->m_font, FALSE ); - - // - // we know we've read in the slider thumb data in the definition file - // (it's guaranteed to be generated by the editor) so place that - // draw data into the thumb of the slider - // - GameWindow *thumb = window->winGetChild(); - if( thumb ) - { - WinInstanceData *instData = thumb->winGetInstanceData(); - - for( Int i = 0; i < MAX_DRAW_DATA; i++ ) - { - - instData->m_enabledDrawData[ i ] = enabledSliderThumbDrawData[ i ]; - instData->m_disabledDrawData[ i ] = disabledSliderThumbDrawData[ i ]; - instData->m_hiliteDrawData[ i ] = hiliteSliderThumbDrawData[ i ]; - - } - - } - - } - else if( strcmp( type, "HORZSLIDER" ) == 0 ) - { - SliderData *sData = (SliderData *)data; - - instData->m_style |= GWS_HORZ_SLIDER; - window = TheWindowManager->gogoGadgetSlider( parent, status, x, y, - width, height, - instData, sData, - instData->m_font, FALSE ); - - // - // we know we've read in the slider thumb data in the definition file - // (it's guaranteed to be generated by the editor) so place that - // draw data into the thumb of the slider - // - GameWindow *thumb = window->winGetChild(); - if( thumb ) - { - WinInstanceData *instData = thumb->winGetInstanceData(); - - for( Int i = 0; i < MAX_DRAW_DATA; i++ ) - { - - instData->m_enabledDrawData[ i ] = enabledSliderThumbDrawData[ i ]; - instData->m_disabledDrawData[ i ] = disabledSliderThumbDrawData[ i ]; - instData->m_hiliteDrawData[ i ] = hiliteSliderThumbDrawData[ i ]; - - } - - } - - } - else if( strcmp( type, "SCROLLLISTBOX" ) == 0 ) - { - - ListboxData *lData = (ListboxData *)data; - - instData->m_style |= GWS_SCROLL_LISTBOX; - window = TheWindowManager->gogoGadgetListBox( parent, status, x, y, - width, height, - instData, lData, - instData->m_font, FALSE ); - - // - // we know that in the file we have read the draw data for the listbox - // parts (up button, down button, and slider), now that we have those - // parts actually created we must assign that data to them - // - GameWindow *upButton = GadgetListBoxGetUpButton( window ); - if( upButton ) - { - WinInstanceData *instData = upButton->winGetInstanceData(); - - for( Int i = 0; i < MAX_DRAW_DATA; i++ ) - { - - instData->m_enabledDrawData[ i ] = enabledUpButtonDrawData[ i ]; - instData->m_disabledDrawData[ i ] = disabledUpButtonDrawData[ i ]; - instData->m_hiliteDrawData[ i ] = hiliteUpButtonDrawData[ i ]; - - } - - } - - GameWindow *downButton = GadgetListBoxGetDownButton( window ); - if( downButton ) - { - WinInstanceData *instData = downButton->winGetInstanceData(); - - for( Int i = 0; i < MAX_DRAW_DATA; i++ ) - { - - instData->m_enabledDrawData[ i ] = enabledDownButtonDrawData[ i ]; - instData->m_disabledDrawData[ i ] = disabledDownButtonDrawData[ i ]; - instData->m_hiliteDrawData[ i ] = hiliteDownButtonDrawData[ i ]; - - } - - } - - GameWindow *slider = GadgetListBoxGetSlider( window ); - if( slider ) - { - WinInstanceData *instData = slider->winGetInstanceData(); - - for( Int i = 0; i < MAX_DRAW_DATA; i++ ) - { - - instData->m_enabledDrawData[ i ] = enabledSliderDrawData[ i ]; - instData->m_disabledDrawData[ i ] = disabledSliderDrawData[ i ]; - instData->m_hiliteDrawData[ i ] = hiliteSliderDrawData[ i ]; - - } - - // do the slider thumb - GameWindow *thumb = slider->winGetChild(); - if( thumb ) - { - WinInstanceData *instData = thumb->winGetInstanceData(); - - for( Int i = 0; i < MAX_DRAW_DATA; i++ ) - { - - instData->m_enabledDrawData[ i ] = enabledSliderThumbDrawData[ i ]; - instData->m_disabledDrawData[ i ] = disabledSliderThumbDrawData[ i ]; - instData->m_hiliteDrawData[ i ] = hiliteSliderThumbDrawData[ i ]; - - } - - } - - } - - } - else if( strcmp( type, "COMBOBOX" ) == 0 ) - { - ComboBoxData *cData = (ComboBoxData *)data; - cData->entryData = NEW EntryData; - memset ( cData->entryData, 0, sizeof(EntryData)); - cData->listboxData = NEW ListboxData; - memset ( cData->listboxData, 0, sizeof(ListboxData)); - - //initialize combo box data - //cData->isEditable = TRUE; - //cData->maxChars = 16; - //cData->maxDisplay = 5; - cData->entryCount = 0; - //initialize entry data - cData->entryData->aSCIIOnly = cData->asciiOnly; - cData->entryData->alphaNumericalOnly = cData->lettersAndNumbersOnly; - cData->entryData->maxTextLen = cData->maxChars; - - //initialize listbox data - cData->listboxData->listLength = 10; - cData->listboxData->autoScroll = 0; - cData->listboxData->scrollIfAtEnd = FALSE; - cData->listboxData->autoPurge = 0; - cData->listboxData->scrollBar = 1; - cData->listboxData->multiSelect = 0; - cData->listboxData->forceSelect = 1; - cData->listboxData->columns = 1; - cData->listboxData->columnWidth = nullptr; - cData->listboxData->columnWidthPercentage = nullptr; - - instData->m_style |= GWS_COMBO_BOX; - window = TheWindowManager->gogoGadgetComboBox( parent, status, x, y, - width, height, - instData, cData, - instData->m_font, FALSE ); - - GameWindow *dropDownButton = GadgetComboBoxGetDropDownButton( window ); - if( dropDownButton ) - { - WinInstanceData *instData = dropDownButton->winGetInstanceData(); - - for( Int i = 0; i < MAX_DRAW_DATA; i++ ) - { - - instData->m_enabledDrawData[ i ] = enabledDropDownButtonDrawData[ i ]; - instData->m_disabledDrawData[ i ] = disabledDropDownButtonDrawData[ i ]; - instData->m_hiliteDrawData[ i ] = hiliteDropDownButtonDrawData[ i ]; - - } - } - - GameWindow *editBox = GadgetComboBoxGetEditBox( window ); - if( editBox ) - { - WinInstanceData *instData = editBox->winGetInstanceData(); - - for( Int i = 0; i < MAX_DRAW_DATA; i++ ) - { - - instData->m_enabledDrawData[ i ] = enabledEditBoxDrawData[ i ]; - instData->m_disabledDrawData[ i ] = disabledEditBoxDrawData[ i ]; - instData->m_hiliteDrawData[ i ] = hiliteEditBoxDrawData[ i ]; - - } - } - - - GameWindow *listBox = GadgetComboBoxGetListBox( window ); - if( listBox ) - { - WinInstanceData *instData = listBox->winGetInstanceData(); - - for( Int i = 0; i < MAX_DRAW_DATA; i++ ) - { - - instData->m_enabledDrawData[ i ] = enabledListBoxDrawData[ i ]; - instData->m_disabledDrawData[ i ] = disabledListBoxDrawData[ i ]; - instData->m_hiliteDrawData[ i ] = hiliteListBoxDrawData[ i ]; - - } - - - GameWindow *upButton = GadgetListBoxGetUpButton( listBox ); - if( upButton ) - { - WinInstanceData *instData = upButton->winGetInstanceData(); - - for( Int i = 0; i < MAX_DRAW_DATA; i++ ) - { - - instData->m_enabledDrawData[ i ] = enabledUpButtonDrawData[ i ]; - instData->m_disabledDrawData[ i ] = disabledUpButtonDrawData[ i ]; - instData->m_hiliteDrawData[ i ] = hiliteUpButtonDrawData[ i ]; - - } - - } - - GameWindow *downButton = GadgetListBoxGetDownButton( listBox ); - if( downButton ) - { - WinInstanceData *instData = downButton->winGetInstanceData(); - - for( Int i = 0; i < MAX_DRAW_DATA; i++ ) - { - - instData->m_enabledDrawData[ i ] = enabledDownButtonDrawData[ i ]; - instData->m_disabledDrawData[ i ] = disabledDownButtonDrawData[ i ]; - instData->m_hiliteDrawData[ i ] = hiliteDownButtonDrawData[ i ]; - - } - - } - - GameWindow *slider = GadgetListBoxGetSlider( listBox ); - if( slider ) - { - WinInstanceData *instData = slider->winGetInstanceData(); - - for( Int i = 0; i < MAX_DRAW_DATA; i++ ) - { - - instData->m_enabledDrawData[ i ] = enabledSliderDrawData[ i ]; - instData->m_disabledDrawData[ i ] = disabledSliderDrawData[ i ]; - instData->m_hiliteDrawData[ i ] = hiliteSliderDrawData[ i ]; - - } - - // do the slider thumb - GameWindow *thumb = slider->winGetChild(); - if( thumb ) - { - WinInstanceData *instData = thumb->winGetInstanceData(); - - for( Int i = 0; i < MAX_DRAW_DATA; i++ ) - { - - instData->m_enabledDrawData[ i ] = enabledSliderThumbDrawData[ i ]; - instData->m_disabledDrawData[ i ] = disabledSliderThumbDrawData[ i ]; - instData->m_hiliteDrawData[ i ] = hiliteSliderThumbDrawData[ i ]; - - } - - } - - } - } - } - else if( strcmp( type, "ENTRYFIELD" ) == 0 ) - { - EntryData *eData = (EntryData *)data; - - instData->m_style |= GWS_ENTRY_FIELD; - window = TheWindowManager->gogoGadgetTextEntry( parent, status, x, y, - width, height, - instData, eData, - instData->m_font, FALSE ); - - } - else if( strcmp( type, "STATICTEXT" ) == 0 ) - { - TextData *tData = (TextData *)data; - - instData->m_style |= GWS_STATIC_TEXT; - window = TheWindowManager->gogoGadgetStaticText( parent, status, x, y, - width, height, - instData, tData, - instData->m_font, FALSE ); - - - } - else if( strcmp( type, "PROGRESSBAR" ) == 0 ) - { - - instData->m_style |= GWS_PROGRESS_BAR; - window = TheWindowManager->gogoGadgetProgressBar( parent, status, x, y, - width, height, - instData, - instData->m_font, FALSE ); - - } - - return window; - -} - -// createWindow =============================================================== -// Create a user window or a gadget depending on the 'type' parm -//============================================================================= -static GameWindow *createWindow( char *type, - Int id, - Int status, - Int x, Int y, - Int width, Int height, - WinInstanceData *instData, - void *data, - GameWinSystemFunc system, - GameWinInputFunc input, - GameWinTooltipFunc tooltip, - GameWinDrawFunc draw ) -{ - GameWindow *window, *parent; - - // Check to see if this window has a parent - parent = peekWindow(); - - // If this is a regular window just create it - if( strcmp( type, "USER" ) == 0 ) - { - - window = TheWindowManager->winCreate( parent, - status, x, y, - width, height, - system ); - if( window ) - { - - instData->m_style |= GWS_USER_WINDOW; - window->winSetInstanceData( instData ); - window->winSetWindowId( id ); - - } - - } - else if( strcmp( type, "TABPANE" ) == 0 ) - { - - window = TheWindowManager->winCreate( parent, - status, x, y, - width, height, - system ); - if( window ) - { - - instData->m_style |= GWS_TAB_PANE; - window->winSetInstanceData( instData ); - window->winSetWindowId( id ); - - } - - } - - else - { - - // Else parse the type and create the gadget - window = createGadget( type, - parent, - status, - x, y, - width, height, - instData, - data ); - if( window ) - { - - // set id - window->winSetWindowId( id ); - - } - - } - - // assign the callbacks if they are not empty/nullptr, that means they were read - // in and parsed from the window definition file - if( window ) - { - - if( system ) - window->winSetSystemFunc( system ); - if( input ) - window->winSetInputFunc( input ); - if( tooltip ) - window->winSetTooltipFunc( tooltip ); - if( draw ) - window->winSetDrawFunc( draw ); - - // save strings for edit data if present - GameWindowEditData *editData = window->winGetEditData(); - if( editData ) - { - - editData->systemCallbackString = theSystemString; - editData->inputCallbackString = theInputString; - editData->tooltipCallbackString = theTooltipString; - editData->drawCallbackString = theDrawString; - - } - - } - - if( window ) - { - - // set any text read from the textLabel - setWindowText( window, instData->m_textLabelString ); - - } - - // If there is a parent window, send it the SCRIPT_CREATE message - if( window && parent ) - TheWindowManager->winSendInputMsg( parent, GWM_SCRIPT_CREATE, id, 0 ); - - return window; - -} - -// parseChildWindows ========================================================== -/** Parse window descriptions until an extra end is encountered indicating - * the end of this block of child window descriptions. */ -//============================================================================= -static Bool parseChildWindows( GameWindow *window, - File *inFile, - char *buffer ) -{ - GameWindow *lastWindow; - AsciiString asciibuf; - - //The gadget with children needs to delete its default created children in favor - //of the ones from the script file. So kill them before reading. - if( BitIsSet( window->winGetStyle(), GWS_TAB_CONTROL ) ) - { - GameWindow *nextWindow = nullptr; - for( GameWindow *myChild = window->winGetChild(); myChild; myChild = nextWindow ) - { - nextWindow = myChild->winGetNext(); - TheWindowManager->winDestroy( myChild ); - } - } - - // Push the current window onto the stack so we know it's the parent - pushWindow( window ); - - while( TRUE ) - { - - if (inFile->scanString(asciibuf) == FALSE) { - break; - } - - if (asciibuf.compare("ENDALLCHILDREN") == 0) { - break; - } - - if (asciibuf.compare("END") == 0) { - break; - } - - if (asciibuf.compare("ENABLEDCOLOR") == 0) - { - - if( parseDefaultColor( &defEnabledColor, inFile, buffer ) == FALSE ) - { - return FALSE; - } - - } - else if (asciibuf.compare("DISABLEDCOLOR") == 0) - { - - if( parseDefaultColor( &defDisabledColor, inFile, buffer ) == FALSE ) - { - return FALSE; - } - - } - else if (asciibuf.compare("HILITECOLOR") == 0) - { - - if( parseDefaultColor( &defHiliteColor, inFile, buffer ) == FALSE ) - { - return FALSE; - } - - } - else if (asciibuf.compare("SELECTEDCOLOR") == 0) - { - - if( parseDefaultColor( &defSelectedColor, inFile, buffer ) == FALSE ) - { - return FALSE; - } - - } - else if (asciibuf.compare("TEXTCOLOR") == 0) - { - - if( parseDefaultColor( &defTextColor, inFile, buffer ) == FALSE ) - { - return FALSE; - } - - } - else if (asciibuf.compare("WINDOW") == 0) - { - - // Parse window descriptions until the last END is read - if( parseWindow( inFile, buffer ) == nullptr ) - { - return FALSE; - } - - } - - } - - // Pop the current window off the stack - lastWindow = popWindow(); - - if( lastWindow != window ) - { - - DEBUG_LOG(( "parseChildWindows: unmatched window on stack. Corrupt stack or bad source" )); - return FALSE; - - } - - if( BitIsSet( window->winGetStyle(), GWS_TAB_CONTROL ) ) - GadgetTabControlFixupSubPaneList( window );//all children created, so re-fill SubPane array with children - - return TRUE; - -} - -// lookup table for parsing functions -static GameWindowParse gameWindowFieldList[] = -{ - { "NAME", parseName }, - { "STATUS", parseStatus }, - { "STYLE", parseStyle }, - { "SYSTEMCALLBACK", parseSystemCallback }, - { "INPUTCALLBACK", parseInputCallback }, - { "TOOLTIPCALLBACK", parseTooltipCallback }, - { "DRAWCALLBACK", parseDrawCallback }, - { "FONT", parseFont }, - { "HEADERTEMPLATE", parseHeaderTemplate }, - { "LISTBOXDATA", parseListboxData }, - { "COMBOBOXDATA", parseComboBoxData }, - { "SLIDERDATA", parseSliderData }, - { "RADIOBUTTONDATA", parseRadioButtonData }, - { "TOOLTIPTEXT", parseTooltipText }, - { "TOOLTIPDELAY", parseTooltipDelay }, - { "TEXT", parseText }, - { "TEXTCOLOR", parseTextColor }, - { "STATICTEXTDATA", parseStaticTextData }, - { "TEXTENTRYDATA", parseTextEntryData }, - { "TABCONTROLDATA", parseTabControlData }, - - { "ENABLEDDRAWDATA", parseDrawData }, - { "DISABLEDDRAWDATA", parseDrawData }, - { "HILITEDRAWDATA", parseDrawData }, - { "LISTBOXENABLEDUPBUTTONDRAWDATA", parseDrawData }, - { "LISTBOXENABLEDDOWNBUTTONDRAWDATA", parseDrawData }, - { "LISTBOXENABLEDSLIDERDRAWDATA", parseDrawData }, - { "LISTBOXDISABLEDUPBUTTONDRAWDATA", parseDrawData }, - { "LISTBOXDISABLEDDOWNBUTTONDRAWDATA", parseDrawData }, - { "LISTBOXDISABLEDSLIDERDRAWDATA", parseDrawData }, - { "LISTBOXHILITEUPBUTTONDRAWDATA", parseDrawData }, - { "LISTBOXHILITEDOWNBUTTONDRAWDATA", parseDrawData }, - { "LISTBOXHILITESLIDERDRAWDATA", parseDrawData }, - { "SLIDERTHUMBENABLEDDRAWDATA", parseDrawData }, - { "SLIDERTHUMBDISABLEDDRAWDATA", parseDrawData }, - { "SLIDERTHUMBHILITEDRAWDATA", parseDrawData }, - - { "COMBOBOXDROPDOWNBUTTONENABLEDDRAWDATA", parseDrawData }, - { "COMBOBOXDROPDOWNBUTTONDISABLEDDRAWDATA", parseDrawData }, - { "COMBOBOXDROPDOWNBUTTONHILITEDRAWDATA", parseDrawData }, - { "COMBOBOXEDITBOXENABLEDDRAWDATA", parseDrawData }, - { "COMBOBOXEDITBOXDISABLEDDRAWDATA", parseDrawData }, - { "COMBOBOXEDITBOXHILITEDRAWDATA", parseDrawData }, - { "COMBOBOXLISTBOXENABLEDDRAWDATA", parseDrawData }, - { "COMBOBOXLISTBOXDISABLEDDRAWDATA", parseDrawData }, - { "COMBOBOXLISTBOXHILITEDRAWDATA", parseDrawData }, - - { "IMAGEOFFSET", parseImageOffset }, - { "TOOLTIP", parseTooltip }, - - { nullptr, nullptr } -}; - -// parseWindow ================================================================ -/** Parse a WINDOW entry in the script. */ -//============================================================================= -static GameWindow *parseWindow( File *inFile, char *buffer ) -{ - GameWindowParse *parse; - GameWindow *window = nullptr; - GameWindow *parent = peekWindow(); - WinInstanceData instData; - char type[64]; - char token[ 256 ]; - char *c; - Int x, y, width, height; - void *data = nullptr; - ICoord2D parentSize; - AsciiString asciibuf; - - // - // reset our 'static globals' that house the current parsed window callback - // definitions to empty - // - systemFunc = nullptr; - inputFunc = nullptr; - tooltipFunc = nullptr; - drawFunc = nullptr; - theSystemString.clear(); - theInputString.clear(); - theTooltipString.clear(); - theDrawString.clear(); - - // get the size of the parent, or if no parent present the screen - if( parent ) - { - parent->winGetSize( &parentSize.x, &parentSize.y ); - } - else - { - parentSize.x = TheDisplay->getWidth(); - parentSize.y = TheDisplay->getHeight(); - } - - // Initialize the instance data to the defaults - /// @todo need to support enabled/disabled/hilite text colors here - instData.init(); - instData.m_enabledText.color = defTextColor; - instData.m_enabledText.borderColor = defTextColor; - instData.m_disabledText.color = defTextColor; - instData.m_disabledText.borderColor = defTextColor; - instData.m_hiliteText.color = defTextColor; - instData.m_hiliteText.borderColor = defTextColor; - - /// @todo need real font support here - instData.m_font = defFont; - - // - // read the first few lines that are required to be first in a - // window definition file including position, size, type, and id - // - - // window type - readUntilSemicolon( inFile, buffer, WIN_BUFFER_LENGTH ); - c = strtok( buffer, seps ); - assert( strcmp( c, "WINDOWTYPE" ) == 0 ); - c = strtok( nullptr, seps ); // get data to right of = sign - strlcpy(type, c, ARRAY_SIZE(type)); - - // - // based on the window type get a pointer for any specific data - // for the gadget controls needed - // - data = getDataTemplate( type ); - - // position - readUntilSemicolon( inFile, buffer, WIN_BUFFER_LENGTH ); - c = strtok( buffer, seps ); - assert( strcmp( c, "SCREENRECT" ) == 0 ); - if( parseScreenRect( c, buffer, &x, &y, &width, &height ) == FALSE ) - goto cleanupAndExit; - - // parse all the field definitions - while( TRUE ) - { - - // get token - inFile->scanString(asciibuf); - - // parse field - for( parse = gameWindowFieldList; parse->parse; parse++ ) - { - - if (asciibuf.compare(parse->name) == 0) - { - - strlcpy(token, asciibuf.str(), ARRAY_SIZE(token)); - - // eat '=' - inFile->scanString(asciibuf); - - readUntilSemicolon( inFile, buffer, WIN_BUFFER_LENGTH ); - - if (parse->parse( token, &instData, buffer, data ) == FALSE ) - { - DEBUG_LOG(( "parseGameObject: Error parsing %s", parse->name )); - goto cleanupAndExit; - } - - break; - } - - } - - if( parse->parse == nullptr ) - { - - // If it's the END keyword - if (asciibuf.compare("DATA") == 0) - { - - // eat '=' - inFile->scanString(asciibuf); - - readUntilSemicolon( inFile, buffer, WIN_BUFFER_LENGTH ); - - if( parseData( &data, type, buffer ) == FALSE ) - { - DEBUG_LOG(( "parseGameWindow: Error parsing %s", parse->name )); - goto cleanupAndExit; - } - - } - else if (asciibuf.compare("END") == 0) - { - // Check to see if we have a header template, if so, set the font equal to that. - if(TheHeaderTemplateManager->getFontFromTemplate(instData.m_headerTemplateName)) - instData.m_font = TheHeaderTemplateManager->getFontFromTemplate(instData.m_headerTemplateName); - - // Create a window using the current description - if( window == nullptr ) - window = createWindow( type, instData.m_id, instData.getStatus(), x, y, - width, height, &instData, data, - systemFunc, inputFunc, tooltipFunc, drawFunc ); - - - goto cleanupAndExit; - - } - else if (asciibuf.compare("CHILD") == 0) - { - - // Create a window using the current description - window = createWindow( type, instData.m_id, instData.getStatus(), x, y, - width, height, &instData, data, - systemFunc, inputFunc, tooltipFunc, drawFunc ); - - if (window == nullptr) - goto cleanupAndExit; - - // Parses the CHILD's window info. - if( parseChildWindows( window, inFile, buffer ) == FALSE ) - { - - TheWindowManager->winDestroy( window ); - window = nullptr; - goto cleanupAndExit; - - } - - } - else - { - - // Else it is unrecognized so eat associated data - readUntilSemicolon( inFile, buffer, WIN_BUFFER_LENGTH ); - - } - - } - - } - -cleanupAndExit: - - // - // this should be true since we should never set the text in - // display strings in a instance data that is not inside a - // window ... it's for sanity checking - // - // I am commenting this out to get tooltips working, If for - // some reason we start having displayString problems... CLH -// assert( instData.m_text == nullptr && instData.m_tooltip == nullptr ); - - return window; - -} - -//================================================================================================= -//================================================================================================= -//================================================================================================= - -//------------------------------------------------------------------------------------------------- -/** Parse init for layout file */ -//------------------------------------------------------------------------------------------------- -Bool parseInit( const char *token, char *buffer, UnsignedInt version, WindowLayoutInfo *info ) -{ - char *c; - const char *seps = " \n\r\t"; - - // get string - c = strtok( buffer, seps ); - - // translate string to function address - info->initNameString = c; - info->init = TheFunctionLexicon->winLayoutInitFunc( TheNameKeyGenerator->nameToKey( info->initNameString ) ); - - return TRUE; // success - -} - -//------------------------------------------------------------------------------------------------- -/** Parse update for layout file */ -//------------------------------------------------------------------------------------------------- -Bool parseUpdate( const char *token, char *buffer, UnsignedInt version, WindowLayoutInfo *info ) -{ - char *c; - const char *seps = " \n\r\t"; - - // get string - c = strtok( buffer, seps ); - - // translate string to function address - info->updateNameString = c; - info->update = TheFunctionLexicon->winLayoutUpdateFunc( TheNameKeyGenerator->nameToKey( info->updateNameString ) ); - - return TRUE; // success - -} - -//------------------------------------------------------------------------------------------------- -/** Parse shutdown for layout file */ -//------------------------------------------------------------------------------------------------- -Bool parseShutdown( const char *token, char *buffer, UnsignedInt version, WindowLayoutInfo *info ) -{ - char *c; - const char *seps = " \n\r\t"; - - // get string - c = strtok( buffer, seps ); - - // translate string to function address - info->shutdownNameString = c; - info->shutdown = TheFunctionLexicon->winLayoutShutdownFunc( TheNameKeyGenerator->nameToKey( info->shutdownNameString ) ); - - return TRUE; // success - -} - -static LayoutScriptParse layoutScriptTable[] = -{ - { "LAYOUTINIT", parseInit }, - { "LAYOUTUPDATE", parseUpdate }, - { "LAYOUTSHUTDOWN", parseShutdown }, - - { nullptr, nullptr }, - -}; - -//------------------------------------------------------------------------------------------------- -/** Parse the layout block which MUST be present in every window file */ -//------------------------------------------------------------------------------------------------- -Bool parseLayoutBlock( File *inFile, char *buffer, UnsignedInt version, WindowLayoutInfo *info ) -{ - LayoutScriptParse *parse; - char token[ 256 ]; - - AsciiString asciitoken; - if (inFile->scanString(asciitoken) == FALSE) { - return FALSE; - } - - // better be the layout block - if (asciitoken.compare("STARTLAYOUTBLOCK") != 0) { - return FALSE; - } - - while( TRUE ) - { - - // get next token - inFile->scanString(asciitoken); - - // check for end - if (asciitoken.compare("ENDLAYOUTBLOCK") == 0) { - break; - } - - // search for token in the table - for( parse = layoutScriptTable; parse && parse->name; parse++ ) - { - - if (asciitoken.compare(parse->name) == 0) - { - char *c; - - // read from file - readUntilSemicolon( inFile, buffer, WIN_BUFFER_LENGTH ); - - // eat equals separator " = " - c = strtok( buffer, " =" ); - - strlcpy(token, asciitoken.str(), ARRAY_SIZE(token)); - - // parse it - if( parse->parse( token, c, version, info ) == FALSE ) - return FALSE; - - break; // exit for - - } - - } - - } - - return TRUE; - -} - -/////////////////////////////////////////////////////////////////////////////// -// PUBLIC FUNCTIONS /////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -// GameWindowManager::winCreateLayout ========================================= -/** Load window(s) from a .wnd definition file and wrap within a - * new window layout */ -//============================================================================= -WindowLayout *GameWindowManager::winCreateLayout( AsciiString filename ) -{ - WindowLayout *layout; - - // allocate a new window layout - layout = newInstance(WindowLayout); - - // load windows into layout - if( layout->load( filename ) == FALSE ) - { - - deleteInstance(layout); - return nullptr; - - } - - // return loaded layout - return layout; - -} - -/** Free up the memory used by static strings. Normally this memory -is freed by the string destructor but we do it here to make the -memory leak detection code happy.*/ -void GameWindowManager::freeStaticStrings() -{ - theSystemString.clear(); - theInputString.clear(); - theTooltipString.clear(); - theDrawString.clear(); -} - -WindowLayoutInfo::WindowLayoutInfo() : - version(0), - init(nullptr), - update(nullptr), - shutdown(nullptr), - initNameString(AsciiString::TheEmptyString), - updateNameString(AsciiString::TheEmptyString), - shutdownNameString(AsciiString::TheEmptyString) -{ - windows.clear(); -} - -// GameWindowManager::winCreateFromScript ===================================== -/** Parse through a window .wnd file and create all the windows - * within it. - * - * NOTE: The FIRST window created from the script is returned, this - * way if you want to know ALL of the windows created from this - * layout file you must iterate over info->windows, since the windows will - * not be at the head of the window list if there is a modal window active. - */ -//============================================================================= -GameWindow *GameWindowManager::winCreateFromScript( AsciiString filenameString, - WindowLayoutInfo *info ) -{ - const char* filename = filenameString.str(); - static char buffer[ WIN_BUFFER_LENGTH ]; // input buffer for reading - GameWindow *firstWindow = nullptr; - GameWindow *window; - char filepath[ _MAX_PATH ] = "Window\\"; - File *inFile; - WindowLayoutInfo scriptInfo; - AsciiString asciibuf; - - // zero info struct - //memset( &scriptInfo, 0, sizeof( WindowLayoutInfo ) ); // it's a class - use a constructor - - // Reset the window stack - resetWindowStack(); - resetWindowDefaults(); - - // - // get the filename from the parameter, if it doesn't contain a '\' it is - // a it is assumed to be a filename only, which we will prefix a "window\" - // directory to, otherwise it is assumed to be an absolute path. When using - // a filename only make sure the current directory is set to the right - // place for the window files subdirectory - // - if( strchr( filename, '\\' ) == nullptr ) - snprintf( filepath, ARRAY_SIZE(filepath), "Window\\%s", filename ); - else - strlcpy(filepath, filename, ARRAY_SIZE(filepath)); - - // Open the input file - inFile = TheFileSystem->openFile(filepath, File::READ); - if (inFile == nullptr) - { - DEBUG_LOG(( "WinCreateFromScript: Cannot access file '%s'.", filename )); - return nullptr; - } - - // read the file version - Int version; - inFile->read(nullptr, strlen("FILE_VERSION = ")); - inFile->scanInt(version); - inFile->nextLine(); - - // version 2+ have a special block called the layout block - if( version >= 2 ) - { - - if( parseLayoutBlock( inFile, buffer, version, &scriptInfo ) == FALSE ) - { - - DEBUG_LOG(( "WinCreateFromScript: Error parsing layout block" )); - return FALSE; - - } - - } - else - { - - // default none names - scriptInfo.initNameString = "[None]"; - scriptInfo.updateNameString = "[None]"; - scriptInfo.shutdownNameString = "[None]"; - - } - - while( TRUE ) - { - - if (inFile->scanString(asciibuf) == FALSE) { - break; - } - - if (asciibuf.compare("END") == 0) { - continue; - } - - if (asciibuf.compare("ENABLEDCOLOR") == 0) - { - - if( parseDefaultColor( &defEnabledColor, inFile, buffer ) == FALSE ) - { - inFile->close(); - inFile = nullptr; - return nullptr; - } - - } - else if (asciibuf.compare("DISABLEDCOLOR") == 0) - { - - if( parseDefaultColor( &defDisabledColor, inFile, buffer ) == FALSE ) - { - inFile->close(); - inFile = nullptr; - return nullptr; - } - - } - else if (asciibuf.compare("HILITECOLOR") == 0) - { - - if( parseDefaultColor( &defHiliteColor, inFile, buffer ) == FALSE ) - { - inFile->close(); - inFile = nullptr; - return nullptr; - } - - } - else if (asciibuf.compare("SELECTEDCOLOR") == 0) - { - - if( parseDefaultColor( &defSelectedColor, inFile, buffer ) == FALSE ) - { - inFile->close(); - inFile = nullptr; - return nullptr; - } - - } - else if (asciibuf.compare("TEXTCOLOR") == 0) - { - - if( parseDefaultColor( &defTextColor, inFile, buffer ) == FALSE ) - { - inFile->close(); - inFile = nullptr; - return nullptr; - } - - } - else if (asciibuf.compare("BACKGROUNDCOLOR") == 0) - { - - if( parseDefaultColor( &defBackgroundColor, inFile, buffer ) == FALSE ) - { - inFile->close(); - inFile = nullptr; - return nullptr; - } - - } - else if (asciibuf.compare("FONT") == 0) - { - - if( parseDefaultFont( defFont, inFile, buffer ) == FALSE ) - { - inFile->close(); - inFile = nullptr; - return nullptr; - } - - } - else if (asciibuf.compare("WINDOW") == 0) - { - - // Parse window descriptions until the last END is read - window = parseWindow( inFile, buffer ); - - // save first window created - if( firstWindow == nullptr ) - firstWindow = window; - - scriptInfo.windows.push_back(window); - - } - - } - - // close the file - inFile->close(); - inFile = nullptr; - - // if info parameter is provided, copy info to the param - if( info ) - *info = scriptInfo; - - // return the first window created - return firstWindow; - -} - diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitionsStyles.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitionsStyles.cpp deleted file mode 100644 index b1998d0ab97..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitionsStyles.cpp +++ /dev/null @@ -1,2243 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** 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 3 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, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: GameWindowTransitionsStyles.cpp ///////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Electronic Arts Pacific. -// -// Confidential Information -// Copyright (C) 2002 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// created: Dec 2002 -// -// Filename: GameWindowTransitionsStyles.cpp -// -// author: Chris Huybregts -// -// purpose: The Actual Styles that can fire off. -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -//----------------------------------------------------------------------------- -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -//----------------------------------------------------------------------------- -// USER INCLUDES ////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -#include "Common/AudioEventRTS.h" -#include "Common/GameAudio.h" -#include "GameClient/GameWindowTransitions.h" -#include "GameClient/GameWindow.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/Display.h" -#include "GameClient/DisplayStringManager.h" -#include "GameClient/GadgetPushButton.h" -#include "GameClient/GadgetStaticText.h" -#include "GameClient/ControlBar.h" - -//----------------------------------------------------------------------------- -// DEFINES //////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -static void drawTypeText( GameWindow *window, DisplayString *str); -//----------------------------------------------------------------------------- -// PUBLIC FUNCTIONS /////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -Transition::Transition () -{ - -} - -Transition::~Transition() -{ - -} -//----------------------------------------------------------------------------- - -FlashTransition::FlashTransition () -{ - m_frameLength = FLASHTRANSITION_END; - m_win = nullptr; - m_drawState = -1; - m_isForward = TRUE; -} - -FlashTransition::~FlashTransition() -{ - m_win = nullptr; -} - -void FlashTransition::init( GameWindow *win ) -{ - if(win) - { - m_win = win; - m_win->winGetSize(&m_size.x, &m_size.y); - m_win->winGetScreenPosition(&m_pos.x, &m_pos.y ); - } - m_isForward = FALSE; - update(FLASHTRANSITION_START); - m_isFinished = FALSE; - m_isForward = TRUE; - -} - -void FlashTransition::update( Int frame ) -{ - m_drawState = -1; - if(frame < FLASHTRANSITION_START || frame > FLASHTRANSITION_END) - { - DEBUG_CRASH(("FlashTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case FLASHTRANSITION_START: - { - - if(m_isForward || !m_win) - break; - m_win->winHide(TRUE); - m_isFinished = TRUE; - } - break; - case FLASHTRANSITION_FADE_IN_1: - if(m_isForward) - { - AudioEventRTS buttonClick("GUIBoarderFadeIn"); - - if( TheAudio ) - { - TheAudio->addAudioEvent( &buttonClick ); - } - - } - FALLTHROUGH; - - case FLASHTRANSITION_FADE_IN_2: - case FLASHTRANSITION_FADE_IN_3: - { - if(!m_win) - break; - m_win->winHide(TRUE); - m_drawState = frame; - } - break; - case FLASHTRANSITION_FADE_TO_BACKGROUND_1: - case FLASHTRANSITION_FADE_TO_BACKGROUND_2: - case FLASHTRANSITION_FADE_TO_BACKGROUND_3: - case FLASHTRANSITION_FADE_TO_BACKGROUND_4: - { - if(!m_win) - break; - m_win->winHide(FALSE); - m_drawState = frame; - } - break; - case FLASHTRANSITION_END: - { - if(!m_isForward || !m_win) - break; - m_win->winHide(FALSE); - m_isFinished = TRUE; - } - break; - } - - -} - -void FlashTransition::reverse() -{ - m_isFinished = FALSE; - m_isForward = FALSE; - -} - -void FlashTransition::draw() -{ - switch (m_drawState) - { - case FLASHTRANSITION_FADE_IN_1: - { - TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, GameMakeColor(255, 203, 45,100)); - TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, GameMakeColor(255, 203, 45, 33)); - } - break; - case FLASHTRANSITION_FADE_IN_2: - { - TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, GameMakeColor(255, 203, 45,150)); - TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, GameMakeColor(255, 203, 45, 66)); - } - break; - case FLASHTRANSITION_FADE_IN_3: - { - TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, GameMakeColor(255, 203, 45,200)); - TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, GameMakeColor(255, 203, 45, 99)); - } - break; - case FLASHTRANSITION_FADE_TO_BACKGROUND_1: - { - TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, GameMakeColor(255, 203, 45,250)); - TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, GameMakeColor(255, 203, 45, 75)); - } - break; - case FLASHTRANSITION_FADE_TO_BACKGROUND_2: - { - TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, GameMakeColor(255, 203, 45,250)); - TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, GameMakeColor(255, 203, 45,50)); - } - break; - case FLASHTRANSITION_FADE_TO_BACKGROUND_3: - { - TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, GameMakeColor(255, 203, 45,250)); - TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, GameMakeColor(255, 203, 45, 25)); - } - break; - case FLASHTRANSITION_FADE_TO_BACKGROUND_4: - { - TheDisplay->drawOpenRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, 1, GameMakeColor(255, 203, 45,250)); - TheDisplay->drawFillRect(m_pos.x+1, m_pos.y+1,m_size.x-2, m_size.y, GameMakeColor(255, 203, 45, 10)); - } - break; - } -} - -void FlashTransition::skip() -{ - update(FLASHTRANSITION_END); -} - -//----------------------------------------------------------------------------- - - -ButtonFlashTransition::ButtonFlashTransition () -{ - m_frameLength = BUTTONFLASHTRANSITION_END; - m_win = nullptr; - m_drawState = -1; - m_isForward = TRUE; -} - -ButtonFlashTransition::~ButtonFlashTransition() -{ - m_win = nullptr; -} - -void ButtonFlashTransition::init( GameWindow *win ) -{ - if(win) - { - m_win = win; - m_win->winGetSize(&m_size.x, &m_size.y); - m_win->winGetScreenPosition(&m_pos.x, &m_pos.y ); - } - m_isForward = FALSE; - update(BUTTONFLASHTRANSITION_START); - m_isFinished = FALSE; - m_isForward = TRUE; - m_gradient = (Image *)TheMappedImageCollection->findImageByName("Gradient"); -} - -void ButtonFlashTransition::update( Int frame ) -{ - m_drawState = -1; - if(frame < BUTTONFLASHTRANSITION_START || frame > BUTTONFLASHTRANSITION_END) - { - DEBUG_CRASH(("ButtonFlashTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case BUTTONFLASHTRANSITION_START: - { - - if(m_isForward || !m_win) - break; - m_win->winHide(TRUE); - m_isFinished = TRUE; - } - break; - case BUTTONFLASHTRANSITION_FADE_IN_1: - { - if(!m_win) - break; - m_win->winHide(TRUE); - if(m_isForward) - { - AudioEventRTS buttonClick("GUIButtonsFadeIn"); - - if( TheAudio ) - { - TheAudio->addAudioEvent( &buttonClick ); - } - - m_drawState = frame; - } - else - m_drawState = BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_4; - } - break; - case BUTTONFLASHTRANSITION_FADE_IN_2: - { - if(!m_win) - break; - m_win->winHide(TRUE); - if(m_isForward) - m_drawState = frame; - else - m_drawState = BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_3; - } - break; - case BUTTONFLASHTRANSITION_FADE_IN_3: - { - if(!m_win) - break; - m_win->winHide(TRUE); - if(m_isForward) - m_drawState = frame; - else - m_drawState = BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_2; - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_1: - { - if(!m_win) - break; - m_win->winHide(TRUE); - if(m_isForward) - m_drawState = frame; - else - m_drawState = BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_1; - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_2: - { - if(!m_win) - break; - m_win->winHide(TRUE); - if(m_isForward) - m_drawState = frame; - else - m_drawState = BUTTONFLASHTRANSITION_FADE_IN_3; - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_3: - { - if(!m_win) - break; - m_win->winHide(TRUE); - if(m_isForward) - m_drawState = frame; - else - m_drawState = BUTTONFLASHTRANSITION_FADE_IN_2; - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_4: - { - if(!m_win) - break; - m_win->winHide(TRUE); - if(m_isForward) - m_drawState = frame; - else - m_drawState = BUTTONFLASHTRANSITION_FADE_IN_1; - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_1: - { - if(!m_win) - break; - if(m_isForward) - { -// AudioEventRTS buttonClick("GUIBlip"); -// -// if( TheAudio ) -// { -// TheAudio->addAudioEvent( &buttonClick ); -// } // end if - - m_win->winHide(FALSE); - m_drawState = frame; - } - else - { - - m_win->winHide(TRUE); - m_drawState = BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_4; - } - - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_2: - { - if(!m_win) - break; - if(m_isForward) - { - m_win->winHide(FALSE); - m_drawState = frame; - } - else - { - m_win->winHide(TRUE); - m_drawState = BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_3; - } - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_1: - { - if(!m_win) - break; - if(m_isForward) - { - m_win->winHide(FALSE); - m_drawState = frame; - } - else - { - m_win->winHide(TRUE); - m_drawState = BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_2; - } - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_2: - { - if(!m_win) - break; - if(m_isForward) - { - m_win->winHide(FALSE); - m_drawState = frame; - } - else - { - m_win->winHide(TRUE); - m_drawState = BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_1; - } - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_3: - { - if(!m_win) - break; - if(m_isForward) - { - m_win->winHide(FALSE); - m_drawState = frame; - } - else - { - m_win->winHide(FALSE); - m_drawState = BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_2; - } - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_4: - { - - if(!m_win) - break; - if(m_isForward) - { - m_win->winHide(FALSE); - m_drawState = frame; - } - else - { - m_win->winHide(FALSE); - m_drawState = BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_1; - } - - } - break; - case BUTTONFLASHTRANSITION_END: - { - if(!m_isForward || !m_win) - break; - m_win->winHide(FALSE); - m_isFinished = TRUE; - } - break; - } - if(frame > BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_4 && frame < BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_1) - m_drawState = BUTTONFLASHTRANSITION_SHOW_BACKGROUND; - -} - -void ButtonFlashTransition::reverse() -{ - m_isFinished = FALSE; - m_isForward = FALSE; - -} - -void ButtonFlashTransition::draw() -{ - switch (m_drawState) - { - case BUTTONFLASHTRANSITION_FADE_IN_1: - { - //PushButtonImageDrawThree(m_win, 100); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, GameMakeColor(255, 203, 45,100)); - TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, GameMakeColor(255, 203, 45, 75)); - } - break; - case BUTTONFLASHTRANSITION_FADE_IN_2: - { - //PushButtonImageDrawThree(m_win, 150); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, GameMakeColor(255, 203, 45,150)); - TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, GameMakeColor(255, 203, 45, 150)); - } - break; - case BUTTONFLASHTRANSITION_FADE_IN_3: - { - //PushButtonImageDrawThree(m_win, 200); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, GameMakeColor(255, 203, 45,200)); - TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, GameMakeColor(255, 203, 45, 200)); - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_1: - { - PushButtonImageDrawThree(m_win, 255); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, GameMakeColor(255, 203, 45,250)); - TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, GameMakeColor(255, 203, 45, 150)); - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_2: - { - PushButtonImageDrawThree(m_win, 255); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, GameMakeColor(255, 203, 45,250)); - TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, GameMakeColor(255, 203, 45,100)); - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_3: - { - PushButtonImageDrawThree(m_win, 255); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, GameMakeColor(255, 203, 45,250)); - TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, GameMakeColor(255, 203, 45, 50)); - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_4: - { - PushButtonImageDrawThree(m_win, 255); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y,m_size.x, m_size.y, 1, GameMakeColor(255, 203, 45,250)); - TheDisplay->drawFillRect(m_pos.x, m_pos.y,m_size.x, m_size.y, GameMakeColor(255, 203, 45, 15)); - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_1: - { - if(m_isForward) - PushButtonImageDrawThree(m_win, 255); - TheDisplay->drawImage(m_gradient, m_pos.x, m_pos.y, m_pos.x +m_size.x, m_pos.y + m_size.y,GameMakeColor(255,255,255,100)); - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_2: - { - TheDisplay->drawImage(m_gradient, m_pos.x, m_pos.y, m_pos.x +m_size.x, m_pos.y + m_size.y,GameMakeColor(255,255,255,200)); - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_1: - { - if(!m_isForward) - PushButtonImageDrawThree(m_win, 255); - - TheDisplay->drawImage(m_gradient, m_pos.x, m_pos.y, m_pos.x +m_size.x, m_pos.y + m_size.y,GameMakeColor(255,255,255,150)); - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_2: - { - if(!m_isForward) - PushButtonImageDrawThree(m_win, 255); - - TheDisplay->drawImage(m_gradient, m_pos.x, m_pos.y, m_pos.x +m_size.x, m_pos.y + m_size.y,GameMakeColor(255,255,255,100)); - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_3: - { - if(!m_isForward) - PushButtonImageDrawThree(m_win, 255); - - TheDisplay->drawImage(m_gradient, m_pos.x, m_pos.y, m_pos.x +m_size.x, m_pos.y + m_size.y,GameMakeColor(255,255,255,50)); - } - break; - case BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_4: - { - if(!m_isForward) - PushButtonImageDrawThree(m_win, 255); - - TheDisplay->drawImage(m_gradient, m_pos.x, m_pos.y, m_pos.x +m_size.x, m_pos.y + m_size.y,GameMakeColor(255,255,255,17)); - } - break; - case BUTTONFLASHTRANSITION_SHOW_BACKGROUND: - { - PushButtonImageDrawThree(m_win, 255); - } - break; - - } -} - -void ButtonFlashTransition::skip() -{ - update(BUTTONFLASHTRANSITION_END); -} - - -//----------------------------------------------------------------------------- - -FadeTransition::FadeTransition () -{ - m_frameLength = FADETRANSITION_END; - m_win = nullptr; - m_drawState = -1; - m_isForward = TRUE; -} - -FadeTransition::~FadeTransition() -{ - m_win = nullptr; -} - -void FadeTransition::init( GameWindow *win ) -{ - if(win) - { - m_win = win; - m_win->winGetSize(&m_size.x, &m_size.y); - m_win->winGetScreenPosition(&m_pos.x, &m_pos.y ); - } - m_isForward = FALSE; - update(FADETRANSITION_START); - m_isFinished = FALSE; - m_isForward = TRUE; -} - -void FadeTransition::update( Int frame ) -{ - m_drawState = -1; - if(frame < FADETRANSITION_START || frame > FADETRANSITION_END) - { - DEBUG_CRASH(("FadeTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case FADETRANSITION_START: - { - - if(m_isForward || !m_win) - break; - m_win->winHide(TRUE); - m_isFinished = TRUE; - } - break; - case FADETRANSITION_FADE_IN_1: - case FADETRANSITION_FADE_IN_2: - case FADETRANSITION_FADE_IN_3: - case FADETRANSITION_FADE_IN_4: - case FADETRANSITION_FADE_IN_5: - case FADETRANSITION_FADE_IN_6: - case FADETRANSITION_FADE_IN_7: - case FADETRANSITION_FADE_IN_8: - case FADETRANSITION_FADE_IN_9: - m_win->winHide(TRUE); - - m_drawState = frame; - break; - case FADETRANSITION_END: - { - if(!m_isForward || !m_win) - break; - m_win->winHide(FALSE); - m_isFinished = TRUE; - } - } -} - -void FadeTransition::reverse() -{ - m_isFinished = FALSE; - m_isForward = FALSE; - -} - -void FadeTransition::draw() -{ - if(!m_win) - return; - if(m_drawState <= FADETRANSITION_START || m_drawState >= FADETRANSITION_END) - return; - const Image *image = m_win->winGetEnabledImage(0); - switch (m_drawState) - { - case FADETRANSITION_FADE_IN_1: - { - TheDisplay->drawImage(image, m_pos.x, m_pos.y, m_pos.x + m_size.x, m_pos.y + m_size.y, GameMakeColor(255, 255, 255, 25)); - } - break; - case FADETRANSITION_FADE_IN_2: - { - TheDisplay->drawImage(image, m_pos.x, m_pos.y, m_pos.x + m_size.x, m_pos.y + m_size.y, GameMakeColor(255, 255, 255, 50)); - } - break; - case FADETRANSITION_FADE_IN_3: - { - TheDisplay->drawImage(image, m_pos.x, m_pos.y, m_pos.x + m_size.x, m_pos.y + m_size.y, GameMakeColor(255, 255, 255, 75)); - } - break; - case FADETRANSITION_FADE_IN_4: - { - TheDisplay->drawImage(image, m_pos.x, m_pos.y, m_pos.x + m_size.x, m_pos.y + m_size.y, GameMakeColor(255, 255, 255, 100)); - } - break; - case FADETRANSITION_FADE_IN_5: - { - TheDisplay->drawImage(image, m_pos.x, m_pos.y, m_pos.x + m_size.x, m_pos.y + m_size.y, GameMakeColor(255, 255, 255, 125)); - } - break; - case FADETRANSITION_FADE_IN_6: - { - TheDisplay->drawImage(image, m_pos.x, m_pos.y, m_pos.x + m_size.x, m_pos.y + m_size.y, GameMakeColor(255, 255, 255, 150)); - } - break; - case FADETRANSITION_FADE_IN_7: - { - TheDisplay->drawImage(image, m_pos.x, m_pos.y, m_pos.x + m_size.x, m_pos.y + m_size.y, GameMakeColor(255, 255, 255, 175)); - } - break; - case FADETRANSITION_FADE_IN_8: - { - TheDisplay->drawImage(image, m_pos.x, m_pos.y, m_pos.x + m_size.x, m_pos.y + m_size.y, GameMakeColor(255, 255, 255, 200)); - } - break; - case FADETRANSITION_FADE_IN_9: - { - TheDisplay->drawImage(image, m_pos.x, m_pos.y, m_pos.x + m_size.x, m_pos.y + m_size.y, GameMakeColor(255, 255, 255, 225)); - } - } -} - -void FadeTransition::skip() -{ - update(FADETRANSITION_END); -} -//----------------------------------------------------------------------------- - -ScaleUpTransition::ScaleUpTransition () -{ - m_frameLength = SCALEUPTRANSITION_END; - m_win = nullptr; - m_drawState = -1; - m_isForward = TRUE; -} - -ScaleUpTransition::~ScaleUpTransition() -{ - m_win = nullptr; -} - -void ScaleUpTransition::init( GameWindow *win ) -{ - if(win) - { - m_win = win; - m_win->winGetSize(&m_size.x, &m_size.y); - m_win->winGetScreenPosition(&m_pos.x, &m_pos.y ); - } - m_isForward = FALSE; - update(SCALEUPTRANSITION_START); - m_isFinished = FALSE; - m_isForward = TRUE; - - m_centerPos.x = m_pos.x + m_size.x / 2; - m_centerPos.y = m_pos.y + m_size.y / 2; - m_incrementSize.x = m_size.x / SCALEUPTRANSITION_END; - m_incrementSize.y = m_size.y / SCALEUPTRANSITION_END; - -} - -void ScaleUpTransition::update( Int frame ) -{ - m_drawState = -1; - if(frame < SCALEUPTRANSITION_START || frame > SCALEUPTRANSITION_END) - { - DEBUG_CRASH(("ScaleUpTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case SCALEUPTRANSITION_START: - { - if(m_isForward || !m_win) - break; - m_win->winHide(TRUE); - m_isFinished = TRUE; - } - break; - case SCALEUPTRANSITION_1: - if(m_isForward) - { - AudioEventRTS buttonClick("GUILogoMouseOver"); - - if( TheAudio ) - { - TheAudio->addAudioEvent( &buttonClick ); - } - - } - FALLTHROUGH; - - case SCALEUPTRANSITION_2: - case SCALEUPTRANSITION_3: - case SCALEUPTRANSITION_4: - case SCALEUPTRANSITION_5: -// case SCALEUPTRANSITION_6: -// case SCALEUPTRANSITION_7: -// case SCALEUPTRANSITION_8: -// case SCALEUPTRANSITION_9: -// case SCALEUPTRANSITION_10: -// case SCALEUPTRANSITION_11: -// case SCALEUPTRANSITION_12: -// case SCALEUPTRANSITION_13: -// case SCALEUPTRANSITION_14: -// case SCALEUPTRANSITION_15: -// case SCALEUPTRANSITION_16: -// case SCALEUPTRANSITION_17: -// case SCALEUPTRANSITION_18: -// case SCALEUPTRANSITION_19: - if(m_win) - m_win->winHide(TRUE); - m_drawState = frame; - break; - case SCALEUPTRANSITION_END: - { - if(!m_isForward || !m_win) - break; - m_win->winHide(FALSE); - m_isFinished = TRUE; - } - } -} - -void ScaleUpTransition::reverse() -{ - m_isFinished = FALSE; - m_isForward = FALSE; - -} - -void ScaleUpTransition::draw() -{ - if(!m_win) - return; - if(m_drawState <= SCALEUPTRANSITION_START || m_drawState >= SCALEUPTRANSITION_END) - return; - const Image *image = m_win->winGetEnabledImage(0); - Int x = m_centerPos.x - ((m_incrementSize.x * m_drawState) / 2); - Int y = m_centerPos.y - ((m_incrementSize.y * m_drawState) / 2); - Int x1 = x + m_incrementSize.x * m_drawState; - Int y1 = y + m_incrementSize.y * m_drawState; - TheDisplay->drawImage(image, x,y, x1, y1); -} - -void ScaleUpTransition::skip() -{ - update(SCALEUPTRANSITION_END); -} - -//----------------------------------------------------------------------------- - -ScoreScaleUpTransition::ScoreScaleUpTransition () -{ - m_frameLength = SCORESCALEUPTRANSITION_END; - m_win = nullptr; - m_drawState = -1; - m_isForward = TRUE; -} - -ScoreScaleUpTransition::~ScoreScaleUpTransition() -{ - m_win = nullptr; -} - -void ScoreScaleUpTransition::init( GameWindow *win ) -{ - if(win) - { - m_win = win; - m_win->winGetSize(&m_size.x, &m_size.y); - m_win->winGetScreenPosition(&m_pos.x, &m_pos.y ); - } - m_isForward = FALSE; - update(SCORESCALEUPTRANSITION_START); - m_isFinished = FALSE; - m_isForward = TRUE; - - m_centerPos.x = m_pos.x + m_size.x / 2; - m_centerPos.y = m_pos.y + m_size.y / 2; - m_incrementSize.x = m_size.x / SCORESCALEUPTRANSITION_END; - m_incrementSize.y = m_size.y / SCORESCALEUPTRANSITION_END; - -} - -void ScoreScaleUpTransition::update( Int frame ) -{ - m_drawState = -1; - if(frame < SCORESCALEUPTRANSITION_START || frame > SCORESCALEUPTRANSITION_END) - { - DEBUG_CRASH(("ScoreScaleUpTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case SCORESCALEUPTRANSITION_START: - { - if(m_isForward || !m_win) - break; - m_win->winHide(TRUE); - m_isFinished = TRUE; - } - break; - case SCORESCALEUPTRANSITION_1: - if(m_isForward) - { - AudioEventRTS buttonClick("GUIScoreScreenPictures"); - - if( TheAudio ) - { - TheAudio->addAudioEvent( &buttonClick ); - } - - } - FALLTHROUGH; - - case SCORESCALEUPTRANSITION_2: - case SCORESCALEUPTRANSITION_3: - case SCORESCALEUPTRANSITION_4: - case SCORESCALEUPTRANSITION_5: -// case SCORESCALEUPTRANSITION_6: -// case SCORESCALEUPTRANSITION_7: -// case SCORESCALEUPTRANSITION_8: -// case SCORESCALEUPTRANSITION_9: -// case SCORESCALEUPTRANSITION_10: -// case SCORESCALEUPTRANSITION_11: -// case SCORESCALEUPTRANSITION_12: -// case SCORESCALEUPTRANSITION_13: -// case SCORESCALEUPTRANSITION_14: -// case SCORESCALEUPTRANSITION_15: -// case SCORESCALEUPTRANSITION_16: -// case SCORESCALEUPTRANSITION_17: -// case SCORESCALEUPTRANSITION_18: -// case SCORESCALEUPTRANSITION_19: - if(m_win) - m_win->winHide(TRUE); - m_drawState = frame; - break; - case SCORESCALEUPTRANSITION_END: - { - if(!m_isForward || !m_win) - break; - m_win->winHide(FALSE); - m_isFinished = TRUE; - } - } -} - -void ScoreScaleUpTransition::reverse() -{ - m_isFinished = FALSE; - m_isForward = FALSE; - -} - -void ScoreScaleUpTransition::draw() -{ - if(!m_win) - return; - if(m_drawState <= SCORESCALEUPTRANSITION_START || m_drawState >= SCORESCALEUPTRANSITION_END) - return; - const Image *image = m_win->winGetEnabledImage(0); - Int x = m_centerPos.x - ((m_incrementSize.x * m_drawState) / 2); - Int y = m_centerPos.y - ((m_incrementSize.y * m_drawState) / 2); - Int x1 = x + m_incrementSize.x * m_drawState; - Int y1 = y + m_incrementSize.y * m_drawState; - TheDisplay->drawImage(image, x,y, x1, y1); -} - -void ScoreScaleUpTransition::skip() -{ - update(SCORESCALEUPTRANSITION_END); -} - -//----------------------------------------------------------------------------- - -MainMenuScaleUpTransition::MainMenuScaleUpTransition () -{ - m_frameLength = MAINMENUSCALEUPTRANSITION_END; - m_win = nullptr; - m_drawState = -1; - m_isForward = TRUE; -} - -MainMenuScaleUpTransition::~MainMenuScaleUpTransition() -{ - m_win = nullptr; -} - -void MainMenuScaleUpTransition::init( GameWindow *win ) -{ - if(win) - { - m_win = win; - m_win->winGetSize(&m_size.x, &m_size.y); - m_win->winGetScreenPosition(&m_pos.x, &m_pos.y ); - } - m_growWin = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinGrowMarker")); - if(!m_growWin) - return; - - m_growWin->winGetSize(&m_growSize.x, &m_growSize.y); - m_growWin->winGetScreenPosition(&m_growPos.x, &m_growPos.y ); - - m_isForward = FALSE; - update(MAINMENUSCALEUPTRANSITION_START); - m_isFinished = FALSE; - m_isForward = TRUE; - m_incrementPos.x = (m_growPos.x - m_pos.x) / MAINMENUSCALEUPTRANSITION_END; - m_incrementPos.y = (m_growPos.y - m_pos.y) / MAINMENUSCALEUPTRANSITION_END; - m_incrementSize.x = (m_growSize.x - m_size.x) / MAINMENUSCALEUPTRANSITION_END; - m_incrementSize.y = (m_growSize.y - m_size.y) / MAINMENUSCALEUPTRANSITION_END; - const Image *image = m_win->winGetDisabledImage(0); - m_growWin->winSetEnabledImage(0, image); - -} - -void MainMenuScaleUpTransition::update( Int frame ) -{ - m_drawState = -1; - if(frame < MAINMENUSCALEUPTRANSITION_START || frame > MAINMENUSCALEUPTRANSITION_END) - { - DEBUG_CRASH(("MainMenuScaleUpTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case MAINMENUSCALEUPTRANSITION_START: - { - - if(m_isForward || !m_win || !m_growWin) - break; -// m_win->winHide(TRUE); - m_growWin->winHide(TRUE); - m_isFinished = TRUE; - } - break; - case MAINMENUSCALEUPTRANSITION_END: - { - if(!m_isForward || !m_win || !m_growWin) - break; - m_win->winHide(TRUE); - m_growWin->winHide(FALSE); - m_isFinished = TRUE; - } - } - if(frame == 1) - { - AudioEventRTS buttonClick("GUILogoSelect"); - - if( TheAudio ) - { - TheAudio->addAudioEvent( &buttonClick ); - } - } - if(frame > MAINMENUSCALEUPTRANSITION_START && frame < MAINMENUSCALEUPTRANSITION_END) - { - if(m_win) - m_win->winHide(TRUE); - if(m_growWin) - m_growWin->winHide(TRUE); - m_drawState = frame; - } - -} - -void MainMenuScaleUpTransition::reverse() -{ - m_isFinished = FALSE; - m_isForward = FALSE; - -} - -void MainMenuScaleUpTransition::draw() -{ - if(!m_win) - return; - if(m_drawState <= MAINMENUSCALEUPTRANSITION_START || m_drawState >= MAINMENUSCALEUPTRANSITION_END) - return; - const Image *image = m_growWin->winGetEnabledImage(0); - Int x = m_pos.x + ((m_incrementPos.x * m_drawState)); - Int y = m_pos.y + ((m_incrementPos.y * m_drawState)); - Int x1 = x + m_size.x + ((m_incrementSize.x * m_drawState)); - Int y1 = y + m_size.y + ((m_incrementSize.y * m_drawState)); - TheDisplay->drawImage(image, x,y, x1, y1); -} - -void MainMenuScaleUpTransition::skip() -{ - update(MAINMENUSCALEUPTRANSITION_END); -} - -//----------------------------------------------------------------------------- - -MainMenuMediumScaleUpTransition::MainMenuMediumScaleUpTransition () -{ - m_frameLength = MAINMENUMEDIUMSCALEUPTRANSITION_END; - m_win = nullptr; - m_drawState = -1; - m_isForward = TRUE; -} - -MainMenuMediumScaleUpTransition::~MainMenuMediumScaleUpTransition() -{ - m_win = nullptr; -} - -void MainMenuMediumScaleUpTransition::init( GameWindow *win ) -{ - if(win) - { - m_win = win; - m_win->winGetSize(&m_size.x, &m_size.y); - m_win->winGetScreenPosition(&m_pos.x, &m_pos.y ); - } - AsciiString growWinName; - growWinName = m_win->winGetInstanceData()->m_decoratedNameString; - growWinName.concat("Medium"); - m_growWin = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey(growWinName)); - if(!m_growWin) - return; - - m_growWin->winGetSize(&m_growSize.x, &m_growSize.y); - m_growWin->winGetScreenPosition(&m_growPos.x, &m_growPos.y ); - - m_isForward = FALSE; - update(MAINMENUMEDIUMSCALEUPTRANSITION_START); - m_isFinished = FALSE; - m_isForward = TRUE; - - m_incrementSize.x = (m_growSize.x - m_size.x) / MAINMENUMEDIUMSCALEUPTRANSITION_END; - m_incrementSize.y = (m_growSize.y - m_size.y) / MAINMENUMEDIUMSCALEUPTRANSITION_END; -// const Image *image = m_win->winGetEnabledImage(0); - //m_growWin->winSetEnabledImage(0, image); - -} - -void MainMenuMediumScaleUpTransition::update( Int frame ) -{ - m_drawState = -1; - if(frame < MAINMENUMEDIUMSCALEUPTRANSITION_START || frame > MAINMENUMEDIUMSCALEUPTRANSITION_END) - { - DEBUG_CRASH(("MainMenuMediumScaleUpTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case MAINMENUMEDIUMSCALEUPTRANSITION_START: - { - - if(m_isForward || !m_win || !m_growWin) - break; - m_win->winHide(FALSE); - m_growWin->winHide(TRUE); - m_isFinished = TRUE; - } - break; - case MAINMENUMEDIUMSCALEUPTRANSITION_END: - { - if(!m_isForward || !m_win || !m_growWin) - break; - m_win->winHide(TRUE); - m_growWin->winHide(FALSE); - m_isFinished = TRUE; - } - } - if(frame > MAINMENUMEDIUMSCALEUPTRANSITION_START && frame < MAINMENUMEDIUMSCALEUPTRANSITION_END) - { - if(frame == 1 && m_isForward) - { - AudioEventRTS buttonClick("GUILogoMouseOver"); - - if( TheAudio ) - { - TheAudio->addAudioEvent( &buttonClick ); - } - } - if(m_win) - m_win->winHide(TRUE); - if(m_growWin) - m_growWin->winHide(TRUE); - m_drawState = frame; - } -} - -void MainMenuMediumScaleUpTransition::reverse() -{ - m_isFinished = FALSE; - m_isForward = FALSE; - m_win->winHide(TRUE); - m_growWin->winHide(TRUE); - -} - -void MainMenuMediumScaleUpTransition::draw() -{ - if(!m_win) - return; - if(m_drawState <= MAINMENUMEDIUMSCALEUPTRANSITION_START || m_drawState >= MAINMENUMEDIUMSCALEUPTRANSITION_END) - return; - const Image *image = m_win->winGetEnabledImage(0); - Int x = m_pos.x - ((m_incrementSize.x * m_drawState) /2); - Int y = m_pos.y - ((m_incrementSize.y * m_drawState) / 2); - Int x1 = m_pos.x + m_size.x + ((m_incrementSize.x * m_drawState) / 2); - Int y1 = m_pos.y + m_size.y + ((m_incrementSize.y * m_drawState) / 2); - TheDisplay->drawImage(image, x,y, x1, y1); -} - -void MainMenuMediumScaleUpTransition::skip() -{ - update(MAINMENUMEDIUMSCALEUPTRANSITION_END); -} -//----------------------------------------------------------------------------- - -MainMenuSmallScaleDownTransition::MainMenuSmallScaleDownTransition () -{ - m_frameLength = MAINMENUSMALLSCALEDOWNTRANSITION_END; - m_win = nullptr; - m_drawState = -1; - m_isForward = TRUE; -} - -MainMenuSmallScaleDownTransition::~MainMenuSmallScaleDownTransition() -{ - m_win = nullptr; -} - -void MainMenuSmallScaleDownTransition::init( GameWindow *win ) -{ - if(win) - { - m_win = win; - m_win->winGetSize(&m_size.x, &m_size.y); - m_win->winGetScreenPosition(&m_pos.x, &m_pos.y ); - } - AsciiString growWinName; - growWinName = m_win->winGetInstanceData()->m_decoratedNameString; - growWinName.concat("Small"); - m_growWin = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey(growWinName)); - if(!m_growWin) - return; - - m_growWin->winGetSize(&m_growSize.x, &m_growSize.y); - m_growWin->winGetScreenPosition(&m_growPos.x, &m_growPos.y ); - - m_isForward = FALSE; - update(MAINMENUSMALLSCALEDOWNTRANSITION_START); - m_isFinished = FALSE; - m_isForward = TRUE; - - m_incrementSize.x = (m_growSize.x - m_size.x) / MAINMENUSMALLSCALEDOWNTRANSITION_END; - m_incrementSize.y = (m_growSize.y - m_size.y) / MAINMENUSMALLSCALEDOWNTRANSITION_END; - const Image *image = m_win->winGetEnabledImage(0); - m_growWin->winSetEnabledImage(0, image); - -} - -void MainMenuSmallScaleDownTransition::update( Int frame ) -{ - m_drawState = -1; - if(frame < MAINMENUSMALLSCALEDOWNTRANSITION_START || frame > MAINMENUSMALLSCALEDOWNTRANSITION_END) - { - DEBUG_CRASH(("MainMenuSmallScaleDownTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case MAINMENUSMALLSCALEDOWNTRANSITION_START: - { - - if(m_isForward || !m_win || !m_growWin) - break; - m_win->winHide(FALSE); - m_growWin->winHide(TRUE); - m_isFinished = TRUE; - } - break; - case MAINMENUSMALLSCALEDOWNTRANSITION_1: - case MAINMENUSMALLSCALEDOWNTRANSITION_2: - case MAINMENUSMALLSCALEDOWNTRANSITION_3: - case MAINMENUSMALLSCALEDOWNTRANSITION_4: - case MAINMENUSMALLSCALEDOWNTRANSITION_5: - if(m_win) - m_win->winHide(TRUE); - if(m_growWin) - m_growWin->winHide(TRUE); - m_drawState = frame; - break; - case MAINMENUSMALLSCALEDOWNTRANSITION_END: - { - if(!m_isForward || !m_win || !m_growWin) - break; - m_win->winHide(TRUE); - m_growWin->winHide(FALSE); - m_isFinished = TRUE; - } - } -} - -void MainMenuSmallScaleDownTransition::reverse() -{ - m_isFinished = FALSE; - m_isForward = FALSE; - -} - -void MainMenuSmallScaleDownTransition::draw() -{ - if(!m_win) - return; - if(m_drawState <= MAINMENUSMALLSCALEDOWNTRANSITION_START || m_drawState >= MAINMENUSMALLSCALEDOWNTRANSITION_END) - return; - const Image *image = m_win->winGetEnabledImage(0); - Int x = m_pos.x - ((m_incrementSize.x * m_drawState) /2); - Int y = m_pos.y - ((m_incrementSize.y * m_drawState) / 2); - Int x1 = m_pos.x + m_size.x + ((m_incrementSize.x * m_drawState) / 2); - Int y1 = m_pos.y + m_size.y + ((m_incrementSize.y * m_drawState) / 2); - TheDisplay->drawImage(image, x,y, x1, y1); -} - -void MainMenuSmallScaleDownTransition::skip() -{ - update(MAINMENUSMALLSCALEDOWNTRANSITION_END); -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -TextTypeTransition::TextTypeTransition () -{ - m_frameLength = TEXTTYPETRANSITION_END; - m_win = nullptr; - m_drawState = -1; - m_isForward = TRUE; - m_dStr = nullptr; -} - -TextTypeTransition::~TextTypeTransition() -{ - m_win = nullptr; - if(m_dStr) - TheDisplayStringManager->freeDisplayString(m_dStr); - m_dStr = nullptr; -} - -void TextTypeTransition::init( GameWindow *win ) -{ - if(win) - { - m_win = win; - m_win->winGetSize(&m_size.x, &m_size.y); - m_win->winGetScreenPosition(&m_pos.x, &m_pos.y ); - } - m_isForward = FALSE; - update(TEXTTYPETRANSITION_START); - m_isFinished = FALSE; - m_isForward = TRUE; - m_dStr = TheDisplayStringManager->newDisplayString(); - m_fullText = GadgetStaticTextGetText(m_win); - Int length = m_fullText.getLength(); - m_frameLength = MIN(length, TEXTTYPETRANSITION_END); -} - -void TextTypeTransition::update( Int frame ) -{ - m_drawState = -1; - if(frame < TEXTTYPETRANSITION_START || frame > TEXTTYPETRANSITION_END) - { - DEBUG_CRASH(("TextTypeTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case TEXTTYPETRANSITION_START: - { - - if(m_isForward || !m_win ) - break; - m_win->winHide(TRUE); - m_isFinished = TRUE; - } - break; - case TEXTTYPETRANSITION_END: - { - if(!m_isForward || !m_win ) - break; - m_win->winHide(FALSE); - m_isFinished = TRUE; - } - } - if(frame >= m_frameLength) - { - m_win->winHide(FALSE); - - } - if(frame > TEXTTYPETRANSITION_START && frame < m_frameLength) - { - m_win->winHide(TRUE); - m_drawState = frame; - AudioEventRTS buttonClick("GUITypeText"); - - if( TheAudio ) - { - TheAudio->addAudioEvent( &buttonClick ); - } - if(m_isForward) - { - m_partialText.concat(m_fullText.getCharAt(frame - 1)); - } - else - { - m_partialText.removeLastChar(); - } - } -} - -void TextTypeTransition::reverse() -{ - m_isFinished = FALSE; - m_isForward = FALSE; - - m_partialText = m_fullText; -} - -void TextTypeTransition::draw() -{ - if(m_drawState > TEXTTYPETRANSITION_START && m_drawState < m_frameLength) - { - m_dStr->setText(m_partialText); - drawTypeText(m_win, m_dStr); - } -} - -void TextTypeTransition::skip() -{ - update(TEXTTYPETRANSITION_END); -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -CountUpTransition::CountUpTransition () -{ - m_frameLength = COUNTUPTRANSITION_END; - m_win = nullptr; - m_drawState = -1; - m_isForward = TRUE; - -} - -CountUpTransition::~CountUpTransition() -{ - m_win = nullptr; -} - -void CountUpTransition::init( GameWindow *win ) -{ - if(win) - { - m_win = win; - m_win->winGetSize(&m_size.x, &m_size.y); - m_win->winGetScreenPosition(&m_pos.x, &m_pos.y ); - - if( m_win->winIsHidden() ) - { - m_isForward = TRUE; - m_isFinished = TRUE; - m_frameLength = 0; - return; - } - } - m_fullText = GadgetStaticTextGetText(m_win); - m_isForward = FALSE; - update(COUNTUPTRANSITION_START); - m_isFinished = FALSE; - m_isForward = TRUE; - - AsciiString tempStr; - tempStr.translate(m_fullText); - m_intValue = atoi(tempStr.str()); - DEBUG_LOG(("CountUpTransition::init %hs %s %d", m_fullText.str(), tempStr.str(), m_intValue)); - if(m_intValue < COUNTUPTRANSITION_END) - { - m_countState = COUNT_ONES; - m_frameLength = MIN(m_intValue, COUNTUPTRANSITION_END); - } - else if(m_intValue/100 < COUNTUPTRANSITION_END) - { - m_countState = COUNT_100S; - m_frameLength = MIN(m_intValue/100, COUNTUPTRANSITION_END); - } - else - { - m_countState = COUNT_1000S; - m_frameLength = MIN(m_intValue/1000, COUNTUPTRANSITION_END); - } - - m_currentValue = 0; - UnicodeString currVal; - currVal.format(L"%d",m_currentValue); - GadgetStaticTextSetText(m_win, currVal); -} - -void CountUpTransition::update( Int frame ) -{ - m_drawState = -1; - if(frame < COUNTUPTRANSITION_START || frame > COUNTUPTRANSITION_END) - { - DEBUG_CRASH(("CountUpTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case COUNTUPTRANSITION_START: - { - - if(m_isForward || !m_win ) - break; - m_currentValue = 0; - UnicodeString currVal; - currVal.format(L"%d",m_currentValue); - GadgetStaticTextSetText(m_win, currVal); - - m_win->winHide(TRUE); - m_isFinished = TRUE; - } - break; - case COUNTUPTRANSITION_END: - { - if(!m_isForward || !m_win ) - break; - m_win->winHide(FALSE); - m_isFinished = TRUE; - } - } - if(frame >= m_frameLength) - { - m_win->winHide(FALSE); - - } - if(frame > COUNTUPTRANSITION_START && frame < m_frameLength) - { - m_win->winHide(FALSE); - m_drawState = frame; - AudioEventRTS buttonClick("GUIScoreScreenTick"); - - if( TheAudio ) - { - TheAudio->addAudioEvent( &buttonClick ); - } - m_currentValue +=m_countState; - if(m_currentValue > m_intValue) - m_currentValue = m_intValue; - - UnicodeString currVal; - currVal.format(L"%d",m_currentValue); - GadgetStaticTextSetText(m_win, currVal); - } - if( frame == m_frameLength ) - { - GadgetStaticTextSetText(m_win, m_fullText); - m_isFinished = TRUE; - } -} - -void CountUpTransition::reverse() -{ - if( m_win->winIsHidden() ) - { - m_isForward = FALSE; - m_isFinished = TRUE; - m_frameLength = 0; - return; - } - m_isFinished = FALSE; - m_isForward = FALSE; - -} - -void CountUpTransition::draw() -{ -} - -void CountUpTransition::skip() -{ - if (!m_isFinished) - update(COUNTUPTRANSITION_END); -} - -//----------------------------------------------------------------------------- - -ScreenFadeTransition::ScreenFadeTransition () -{ - m_frameLength = SCREENFADETRANSITION_END; - m_win = nullptr; - m_drawState = -1; - m_isForward = TRUE; - -} - -ScreenFadeTransition::~ScreenFadeTransition() -{ - m_win = nullptr; - -} - -void ScreenFadeTransition::init( GameWindow *win ) -{ - m_isForward = FALSE; - update(SCREENFADETRANSITION_START); - m_isFinished = FALSE; - m_isForward = TRUE; - - m_percent = 1.0f / (SCREENFADETRANSITION_END - 1); - - m_pos.y = m_pos.x = 0; - m_size.x = TheDisplay->getWidth(); - m_size.y = TheDisplay->getHeight(); - -} - -void ScreenFadeTransition::update( Int frame ) -{ - m_drawState = -1; - if(frame < SCREENFADETRANSITION_START || frame > SCREENFADETRANSITION_END) - { - DEBUG_CRASH(("ScreenFadeTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case SCREENFADETRANSITION_START: - { - m_isFinished = TRUE; - } - break; - case SCREENFADETRANSITION_END: - { - m_isFinished = TRUE; - } - } - m_drawState = frame; -} - -void ScreenFadeTransition::reverse() -{ - m_isFinished = FALSE; - m_isForward = FALSE; -} - -void ScreenFadeTransition::draw() -{ - Int alpha = m_percent*255 *m_drawState; - if(alpha > 255) - alpha = 255; - TheDisplay->drawFillRect(m_pos.x, m_pos.y, m_size.x, m_size.y , GameMakeColor(0,0,0,alpha)); - -} - -void ScreenFadeTransition::skip() -{ - update(SCREENFADETRANSITION_END); -} - - -//----------------------------------------------------------------------------- - -ControlBarArrowTransition::ControlBarArrowTransition () -{ - m_frameLength = CONTROLBARARROWTRANSITION_END; - m_win = nullptr; - m_drawState = -1; - m_isForward = TRUE; - m_arrowImage = nullptr; - -} - -ControlBarArrowTransition::~ControlBarArrowTransition() -{ - m_win = nullptr; - m_arrowImage = nullptr; -} - -void ControlBarArrowTransition::init( GameWindow *win ) -{ - m_isForward = FALSE; - update(CONTROLBARARROWTRANSITION_START); - m_isFinished = FALSE; - m_isForward = TRUE; - - m_percent = 1.0f / CONTROLBARARROWTRANSITION_BEGIN_FADE; - m_fadePercent = 1.0f/ (CONTROLBARARROWTRANSITION_END - CONTROLBARARROWTRANSITION_BEGIN_FADE); - - m_arrowImage = TheControlBar->getArrowImage(); - GameWindow *twin = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey("ControlBar.wnd:ButtonGeneral")); - if(!twin || !m_arrowImage) - { - m_isFinished = TRUE; - return; - } - ICoord2D screenPos, screenSize; - twin->winGetScreenPosition(&screenPos.x, &screenPos.y); - twin->winGetSize(&screenSize.x, &screenSize.y); - - m_incrementPos.x = 0; - m_incrementPos.y = screenPos.y * m_percent; - - m_pos.y = 0 - m_arrowImage->getImageHeight() + 20; - m_pos.x = (screenPos.x + screenSize.x /2) - m_arrowImage->getImageWidth() /2; - - m_size.x = m_arrowImage->getImageWidth(); - m_size.y = m_arrowImage->getImageHeight(); - -} - -void ControlBarArrowTransition::update( Int frame ) -{ - m_drawState = -1; - if(frame < CONTROLBARARROWTRANSITION_START || frame > CONTROLBARARROWTRANSITION_END) - { - DEBUG_CRASH(("ControlBarArrowTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case CONTROLBARARROWTRANSITION_START: - { - m_isFinished = TRUE; - } - break; - case CONTROLBARARROWTRANSITION_END: - { - m_isFinished = TRUE; - } - } - m_drawState = frame; -} - -void ControlBarArrowTransition::reverse() -{ - m_isFinished = FALSE; - m_isForward = FALSE; -} - -void ControlBarArrowTransition::draw() -{ - if(m_drawState < CONTROLBARARROWTRANSITION_START) - return; - if(m_drawState < CONTROLBARARROWTRANSITION_BEGIN_FADE) - { - Int yPos = m_pos.y + m_incrementPos.y* m_drawState; - TheDisplay->drawImage(m_arrowImage, m_pos.x, yPos, m_pos.x + m_size.x, yPos + m_size.y ); - - } - else - { - Int alpha = (1 - (m_fadePercent *(m_drawState - CONTROLBARARROWTRANSITION_BEGIN_FADE )) )*255 ; - if(alpha > 255) - alpha = 255; - Int yPos = m_pos.y + m_incrementPos.y* (CONTROLBARARROWTRANSITION_BEGIN_FADE - 1); - - TheDisplay->drawImage(m_arrowImage, m_pos.x, yPos, m_pos.x + m_size.x, yPos + m_size.y , GameMakeColor(255,255,255,alpha)); - } - -} - -void ControlBarArrowTransition::skip() -{ - update(CONTROLBARARROWTRANSITION_END); -} - - - - - -//----------------------------------------------------------------------------- - -FullFadeTransition::FullFadeTransition () -{ - m_frameLength = FULLFADETRANSITION_END; - m_win = nullptr; - m_drawState = -1; - m_isForward = TRUE; - -} - -FullFadeTransition::~FullFadeTransition() -{ - m_win = nullptr; - -} - -void FullFadeTransition::init( GameWindow *win ) -{ - - if(win) - { - m_win = win; - m_win->winGetSize(&m_size.x, &m_size.y); - m_win->winGetScreenPosition(&m_pos.x, &m_pos.y ); - } - - m_isForward = FALSE; - update(FULLFADETRANSITION_START); - m_isFinished = FALSE; - m_isForward = TRUE; - - m_percent = 1.0f / (FULLFADETRANSITION_END/2); - -} - -void FullFadeTransition::update( Int frame ) -{ - m_drawState = -1; - if(frame < FULLFADETRANSITION_START || frame > FULLFADETRANSITION_END) - { - DEBUG_CRASH(("FullFadeTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case FULLFADETRANSITION_START: - { - - if(m_isForward || !m_win ) - break; - - m_win->winHide(TRUE); - m_isFinished = TRUE; - - } - break; - case FULLFADETRANSITION_END: - { - if(!m_isForward || !m_win ) - break; - m_win->winHide(FALSE); - m_isFinished = TRUE; - - } - } - if(frame == FULLFADETRANSITION_END/2) - { - if(m_isForward) - m_win->winHide(FALSE); - else - m_win->winHide(TRUE); - } - m_drawState = frame; -} - -void FullFadeTransition::reverse() -{ - m_isFinished = FALSE; - m_isForward = FALSE; -} - -void FullFadeTransition::draw() -{ - Int alpha; - if(m_drawState > (FULLFADETRANSITION_END/2)) - alpha = m_percent * 255 * (FULLFADETRANSITION_END - m_drawState); - else - alpha = m_percent * 255 *m_drawState; - if(alpha > 255) - alpha = 255; - TheDisplay->drawFillRect(m_pos.x, m_pos.y, m_size.x, m_size.y , GameMakeColor(0,0,0,alpha)); - TheDisplay->drawOpenRect(m_pos.x, m_pos.y, m_size.x, m_size.y , 1.0f, GameMakeColor(255,190,0,alpha)); -} - -void FullFadeTransition::skip() -{ - update(FULLFADETRANSITION_END); -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -TextOnFrameTransition::TextOnFrameTransition () -{ - m_frameLength = TEXTONFRAMETRANSITION_END; - m_win = nullptr; - m_isForward = TRUE; - -} - -TextOnFrameTransition::~TextOnFrameTransition() -{ - m_win = nullptr; - -} - -void TextOnFrameTransition::init( GameWindow *win ) -{ - - if(win) - { - m_win = win; - } - if(m_win->winIsHidden()) - { - m_isFinished = TRUE; - m_isForward = TRUE; - m_frameLength = 0; - } - else - { - m_isForward = FALSE; - update(TEXTONFRAMETRANSITION_START); - m_isFinished = FALSE; - m_isForward = TRUE; - } -} - -void TextOnFrameTransition::update( Int frame ) -{ - if(frame < TEXTONFRAMETRANSITION_START || frame > TEXTONFRAMETRANSITION_END) - { - DEBUG_CRASH(("TextOnFrameTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case TEXTONFRAMETRANSITION_START: - { - - if(m_isForward || !m_win ) - break; - - m_win->winHide(TRUE); - m_isFinished = TRUE; - - } - break; - case TEXTONFRAMETRANSITION_END: - { - if(!m_isForward || !m_win ) - break; - m_win->winHide(FALSE); - m_isFinished = TRUE; - - } - } -} - -void TextOnFrameTransition::reverse() -{ - m_isFinished = FALSE; - m_isForward = FALSE; - if(m_win->winIsHidden()) - { - m_isFinished = TRUE; - m_frameLength = 0; - } -} - -void TextOnFrameTransition::draw() -{ -} - -void TextOnFrameTransition::skip() -{ - if (!m_isFinished) - update(TEXTONFRAMETRANSITION_END); -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -ReverseSoundTransition::ReverseSoundTransition () -{ - m_frameLength = REVERSESOUNDTRANSITION_END; - m_win = nullptr; - m_isForward = TRUE; - -} - -ReverseSoundTransition::~ReverseSoundTransition() -{ - m_win = nullptr; - -} - -void ReverseSoundTransition::init( GameWindow *win ) -{ - m_isFinished = TRUE; - m_isForward = TRUE; -} - -void ReverseSoundTransition::update( Int frame ) -{ - if(frame < REVERSESOUNDTRANSITION_START || frame > REVERSESOUNDTRANSITION_END) - { - DEBUG_CRASH(("ReverseSoundTransition::update - Frame is out of the range the this update can handle %d", frame)); - return; - } - switch (frame) { - case REVERSESOUNDTRANSITION_START: - { - - if(m_isForward ) - break; - - m_isFinished = TRUE; - - } - break; - - case REVERSESOUNDTRANSITION_FIRESOUND: - { - AudioEventRTS buttonClick("GUITransitionFade"); - - if( TheAudio ) - { - TheAudio->addAudioEvent( &buttonClick ); - } - } - break; - - case REVERSESOUNDTRANSITION_END: - { - if(!m_isForward ) - break; - m_isFinished = TRUE; - - } - } -} - -void ReverseSoundTransition::reverse() -{ - m_isFinished = FALSE; - m_isForward = FALSE; -} - -void ReverseSoundTransition::draw() -{ -} - -void ReverseSoundTransition::skip() -{ - if (!m_isFinished) - update(REVERSESOUNDTRANSITION_END); -} - - - -//----------------------------------------------------------------------------- -// PRIVATE FUNCTIONS ////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -void PushButtonImageDrawThree(GameWindow *window, Int alpha ) -{ - WinInstanceData *instData = window->winGetInstanceData(); - const Image *leftImage, *rightImage, *centerImage; - ICoord2D origin, size, start, end; - Int xOffset, yOffset; - Int i; - Int color = GameMakeColor(255,255,255,alpha); - // get screen position and size - window->winGetScreenPosition( &origin.x, &origin.y ); - window->winGetSize( &size.x, &size.y ); - - // get image offset - xOffset = instData->m_imageOffset.x; - yOffset = instData->m_imageOffset.y; - - leftImage = GadgetButtonGetLeftEnabledImage( window ); - rightImage = GadgetButtonGetRightEnabledImage( window ); - centerImage = GadgetButtonGetMiddleEnabledImage( window ); - - // sanity, we need to have these images to make it look right - if( leftImage == nullptr || rightImage == nullptr || - centerImage == nullptr ) - return; - - // get image sizes for the ends - ICoord2D leftSize, rightSize; - leftSize.x = leftImage->getImageWidth(); - leftSize.y = leftImage->getImageHeight(); - rightSize.x = rightImage->getImageWidth(); - rightSize.y = rightImage->getImageHeight(); - - // get two key points used in the end drawing - ICoord2D leftEnd, rightStart; - leftEnd.x = origin.x + leftSize.x + xOffset; - leftEnd.y = origin.y + size.y + yOffset; - rightStart.x = origin.x + size.x - rightSize.x + xOffset; - rightStart.y = origin.y + yOffset; - - // draw the center repeating bar - Int centerWidth, pieces; - - // get width we have to draw our repeating center in - centerWidth = rightStart.x - leftEnd.x; - - if( centerWidth <= 0) - { - // draw left end - start.x = origin.x + xOffset; - start.y = origin.y + yOffset; - end.y = leftEnd.y; - end.x = origin.x + xOffset + size.x/2; - TheDisplay->drawImage(leftImage, start.x, start.y, end.x, end.y,color); - - // draw right end - start.y = rightStart.y; - start.x = end.x; - end.x = origin.x + size.x; - end.y = start.y + size.y; - TheDisplay->drawImage(rightImage, start.x, start.y, end.x, end.y,color); - } - else - { - - // how many whole repeating pieces will fit in that width - pieces = centerWidth / centerImage->getImageWidth(); - - // draw the pieces - start.x = leftEnd.x; - start.y = origin.y + yOffset; - end.y = start.y + size.y + yOffset; //centerImage->getImageHeight() + yOffset; - for( i = 0; i < pieces; i++ ) - { - - end.x = start.x + centerImage->getImageWidth(); - - TheDisplay->drawImage( centerImage, - start.x, start.y, - end.x, end.y,color ); - start.x += centerImage->getImageWidth(); - - } - - // we will draw the image but clip the parts we don't want to show - IRegion2D reg; - reg.lo.x = start.x; - reg.lo.y = start.y; - reg.hi.x = rightStart.x; - reg.hi.y = end.y; - centerWidth = rightStart.x - start.x; - if( centerWidth > 0) - { - TheDisplay->setClipRegion(®); - end.x = start.x + centerImage->getImageWidth(); - TheDisplay->drawImage( centerImage, - start.x, start.y, - end.x, end.y,color ); - TheDisplay->enableClipping(FALSE); - } - - // draw left end - start.x = origin.x + xOffset; - start.y = origin.y + yOffset; - end = leftEnd; - TheDisplay->drawImage(leftImage, start.x, start.y, end.x, end.y,color); - - // draw right end - start = rightStart; - end.x = start.x + rightSize.x; - end.y = start.y + size.y; - TheDisplay->drawImage(rightImage, start.x, start.y, end.x, end.y,color); - } - -} - -static void drawTypeText( GameWindow *window, DisplayString *str) -{ - TextData *tData = (TextData *)window->winGetUserData(); - Int textColor = window->winGetEnabledTextColor(); - Int textDropColor = window->winGetEnabledTextBorderColor(); - Int textWidth, textHeight, wordWrap; - DisplayString *text = tData->text; - ICoord2D origin, size, textPos; - IRegion2D clipRegion; - // sanity - if( text == nullptr || text->getTextLength() == 0 ) - return; - GameFont *font = text->getFont(); - - str->setFont(font); - - // get window position and size - window->winGetScreenPosition( &origin.x, &origin.y ); - window->winGetSize( &size.x, &size.y ); - - // Set the text Wrap width - wordWrap = size.x - 10; - text->setWordWrap(wordWrap); - str->setWordWrap(wordWrap); - if( BitIsSet(window->winGetStatus(), WIN_STATUS_WRAP_CENTERED) ) - { - str->setWordWrapCentered(TRUE); - text->setWordWrapCentered(TRUE); - } - else - { - text->setWordWrapCentered(FALSE); - str->setWordWrapCentered(FALSE); - - } - - - // how much space will this text take up - text->getSize( &textWidth, &textHeight ); - - //Init the clip region - clipRegion.lo.x = origin.x ; - clipRegion.lo.y = origin.y ; - clipRegion.hi.x = origin.x + size.x ; - clipRegion.hi.y = origin.y + size.y; - - if( tData->centered ) - { - - textPos.x = origin.x + (size.x / 2) - (textWidth / 2); - textPos.y = origin.y + (size.y / 2) - (textHeight / 2); - str->setClipRegion(&clipRegion); - str->draw( textPos.x, textPos.y, textColor, textDropColor ); - } - else - { - - // draw the text - textPos.x = origin.x + 7; - textPos.y = origin.y + (size.y / 2) - (textHeight / 2); - str->setClipRegion(&clipRegion); - str->draw( textPos.x, textPos.y, textColor, textDropColor ); - - } - - -} diff --git a/GeneralsMD/Code/GameEngine/CMakeLists.txt b/GeneralsMD/Code/GameEngine/CMakeLists.txt index a636a00a345..607e05e77e1 100644 --- a/GeneralsMD/Code/GameEngine/CMakeLists.txt +++ b/GeneralsMD/Code/GameEngine/CMakeLists.txt @@ -135,7 +135,7 @@ set(GAMEENGINE_SRC # Include/Common/XferLoad.h # Include/Common/XferSave.h # Include/GameClient/Anim2D.h - Include/GameClient/AnimateWindowManager.h +# Include/GameClient/AnimateWindowManager.h Include/GameClient/CampaignManager.h # Include/GameClient/ChallengeGenerals.h # Include/GameClient/ClientInstance.h @@ -177,8 +177,8 @@ set(GAMEENGINE_SRC # Include/GameClient/GameText.h # Include/GameClient/GameWindow.h # Include/GameClient/GameWindowGlobal.h - Include/GameClient/GameWindowID.h - Include/GameClient/GameWindowManager.h +# Include/GameClient/GameWindowID.h +# Include/GameClient/GameWindowManager.h # Include/GameClient/GameWindowTransitions.h # Include/GameClient/GlobalLanguage.h # Include/GameClient/GraphDraw.h @@ -694,7 +694,7 @@ set(GAMEENGINE_SRC # Source/GameClient/GameText.cpp # Source/GameClient/GlobalLanguage.cpp # Source/GameClient/GraphDraw.cpp - Source/GameClient/GUI/AnimateWindowManager.cpp +# Source/GameClient/GUI/AnimateWindowManager.cpp # Source/GameClient/GUI/ChallengeGenerals.cpp # Source/GameClient/GUI/ControlBar/ControlBar.cpp # Source/GameClient/GUI/ControlBar/ControlBarBeacon.cpp @@ -724,10 +724,10 @@ set(GAMEENGINE_SRC # Source/GameClient/GUI/GameFont.cpp # Source/GameClient/GUI/GameWindow.cpp # Source/GameClient/GUI/GameWindowGlobal.cpp - Source/GameClient/GUI/GameWindowManager.cpp - Source/GameClient/GUI/GameWindowManagerScript.cpp +# Source/GameClient/GUI/GameWindowManager.cpp +# Source/GameClient/GUI/GameWindowManagerScript.cpp # Source/GameClient/GUI/GameWindowTransitions.cpp - Source/GameClient/GUI/GameWindowTransitionsStyles.cpp +# Source/GameClient/GUI/GameWindowTransitionsStyles.cpp # Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp # Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp # Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp diff --git a/scripts/cpp/unify_move_files.py b/scripts/cpp/unify_move_files.py index 567a2465030..a242d9bfda7 100644 --- a/scripts/cpp/unify_move_files.py +++ b/scripts/cpp/unify_move_files.py @@ -696,6 +696,14 @@ def main(): #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/ShellMenuScheme.h", Game.CORE, "GameEngine/Include/GameClient/ShellMenuScheme.h") #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GUI/Shell/ShellMenuScheme.cpp", Game.CORE, "GameEngine/Source/GameClient/GUI/Shell/ShellMenuScheme.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/AnimateWindowManager.h", Game.CORE, "GameEngine/Include/GameClient/AnimateWindowManager.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/GameWindowID.h", Game.CORE, "GameEngine/Include/GameClient/GameWindowID.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/GameWindowManager.h", Game.CORE, "GameEngine/Include/GameClient/GameWindowManager.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp", Game.CORE, "GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GUI/GameWindowManager.cpp", Game.CORE, "GameEngine/Source/GameClient/GUI/GameWindowManager.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp", Game.CORE, "GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GUI/GameWindowTransitionsStyles.cpp", Game.CORE, "GameEngine/Source/GameClient/GUI/GameWindowTransitionsStyles.cpp") + return