diff --git a/Core/GameEngine/CMakeLists.txt b/Core/GameEngine/CMakeLists.txt index 5b119043772..b1499ffa387 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 @@ -164,7 +164,7 @@ set(GAMEENGINE_SRC Include/GameClient/DrawGroupInfo.h # Include/GameClient/EstablishConnectionsMenu.h # Include/GameClient/Eva.h -# Include/GameClient/ExtendedMessageBox.h + Include/GameClient/ExtendedMessageBox.h # Include/GameClient/FontDesc.h Include/GameClient/FXList.h # Include/GameClient/Gadget.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 @@ -193,7 +193,7 @@ set(GAMEENGINE_SRC # Include/GameClient/GUICommandTranslator.h Include/GameClient/HeaderTemplate.h # Include/GameClient/HintSpy.h -# Include/GameClient/HotKey.h + Include/GameClient/HotKey.h Include/GameClient/Image.h Include/GameClient/IMEManager.h # Include/GameClient/InGameUI.h @@ -204,7 +204,7 @@ set(GAMEENGINE_SRC Include/GameClient/LoadScreen.h # Include/GameClient/LookAtXlat.h Include/GameClient/MapUtil.h -# Include/GameClient/MessageBox.h + Include/GameClient/MessageBox.h # Include/GameClient/MetaEvent.h Include/GameClient/Module/AnimatedParticleSysBoneClientUpdate.h Include/GameClient/Module/BeaconClientUpdate.h @@ -705,11 +705,11 @@ set(GAMEENGINE_SRC # Source/GameClient/Eva.cpp Source/GameClient/FXList.cpp # Source/GameClient/GameClient.cpp -# Source/GameClient/GameClientDispatch.cpp + Source/GameClient/GameClientDispatch.cpp 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 @@ -739,14 +739,14 @@ 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/GameWindowManager.cpp # Source/GameClient/GUI/GameWindowManagerScript.cpp Source/GameClient/GUI/GameWindowTransitions.cpp # Source/GameClient/GUI/GameWindowTransitionsStyles.cpp # Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp # Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp # Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp -# Source/GameClient/GUI/GUICallbacks/ExtendedMessageBox.cpp + Source/GameClient/GUI/GUICallbacks/ExtendedMessageBox.cpp # Source/GameClient/GUI/GUICallbacks/GeneralsExpPoints.cpp # Source/GameClient/GUI/GUICallbacks/IMECandidate.cpp # Source/GameClient/GUI/GUICallbacks/InGameChat.cpp @@ -792,7 +792,7 @@ set(GAMEENGINE_SRC # Source/GameClient/GUI/GUICallbacks/Menus/WOLQuickMatchMenu.cpp # Source/GameClient/GUI/GUICallbacks/Menus/WOLStatusMenu.cpp # Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp -# Source/GameClient/GUI/GUICallbacks/MessageBox.cpp + Source/GameClient/GUI/GUICallbacks/MessageBox.cpp # Source/GameClient/GUI/GUICallbacks/ReplayControls.cpp Source/GameClient/GUI/HeaderTemplate.cpp Source/GameClient/GUI/IMEManager.cpp @@ -812,7 +812,7 @@ set(GAMEENGINE_SRC # Source/GameClient/MessageStream/CommandXlat.cpp # Source/GameClient/MessageStream/GUICommandTranslator.cpp # Source/GameClient/MessageStream/HintSpy.cpp -# Source/GameClient/MessageStream/HotKey.cpp + Source/GameClient/MessageStream/HotKey.cpp # Source/GameClient/MessageStream/LookAtXlat.cpp # Source/GameClient/MessageStream/MetaEvent.cpp # Source/GameClient/MessageStream/PlaceEventTranslator.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/ExtendedMessageBox.h b/Core/GameEngine/Include/GameClient/ExtendedMessageBox.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/ExtendedMessageBox.h rename to Core/GameEngine/Include/GameClient/ExtendedMessageBox.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/Include/GameClient/HotKey.h b/Core/GameEngine/Include/GameClient/HotKey.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/HotKey.h rename to Core/GameEngine/Include/GameClient/HotKey.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/MessageBox.h b/Core/GameEngine/Include/GameClient/MessageBox.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/MessageBox.h rename to Core/GameEngine/Include/GameClient/MessageBox.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/GUICallbacks/ExtendedMessageBox.cpp b/Core/GameEngine/Source/GameClient/GUI/GUICallbacks/ExtendedMessageBox.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ExtendedMessageBox.cpp rename to Core/GameEngine/Source/GameClient/GUI/GUICallbacks/ExtendedMessageBox.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/MessageBox.cpp b/Core/GameEngine/Source/GameClient/GUI/GUICallbacks/MessageBox.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/MessageBox.cpp rename to Core/GameEngine/Source/GameClient/GUI/GUICallbacks/MessageBox.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/GameClientDispatch.cpp b/Core/GameEngine/Source/GameClient/GameClientDispatch.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/GameClientDispatch.cpp rename to Core/GameEngine/Source/GameClient/GameClientDispatch.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp b/Core/GameEngine/Source/GameClient/MessageStream/HotKey.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp rename to Core/GameEngine/Source/GameClient/MessageStream/HotKey.cpp diff --git a/Generals/Code/GameEngine/CMakeLists.txt b/Generals/Code/GameEngine/CMakeLists.txt index 539e7711fa1..304a5fc104e 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 @@ -151,7 +151,7 @@ set(GAMEENGINE_SRC # Include/GameClient/DrawGroupInfo.h Include/GameClient/EstablishConnectionsMenu.h Include/GameClient/Eva.h - Include/GameClient/ExtendedMessageBox.h +# Include/GameClient/ExtendedMessageBox.h Include/GameClient/FontDesc.h # Include/GameClient/FXList.h Include/GameClient/Gadget.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 @@ -180,7 +180,7 @@ set(GAMEENGINE_SRC Include/GameClient/GUICommandTranslator.h # Include/GameClient/HeaderTemplate.h Include/GameClient/HintSpy.h - Include/GameClient/HotKey.h +# Include/GameClient/HotKey.h # Include/GameClient/Image.h # Include/GameClient/IMEManager.h Include/GameClient/InGameUI.h @@ -191,7 +191,7 @@ set(GAMEENGINE_SRC # Include/GameClient/LoadScreen.h Include/GameClient/LookAtXlat.h # Include/GameClient/MapUtil.h - Include/GameClient/MessageBox.h +# Include/GameClient/MessageBox.h Include/GameClient/MetaEvent.h # Include/GameClient/Module/AnimatedParticleSysBoneClientUpdate.h # Include/GameClient/Module/BeaconClientUpdate.h @@ -649,11 +649,11 @@ set(GAMEENGINE_SRC Source/GameClient/Eva.cpp # Source/GameClient/FXList.cpp Source/GameClient/GameClient.cpp - Source/GameClient/GameClientDispatch.cpp +# Source/GameClient/GameClientDispatch.cpp # 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,14 +683,14 @@ 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/GameWindowManager.cpp Source/GameClient/GUI/GameWindowManagerScript.cpp # Source/GameClient/GUI/GameWindowTransitions.cpp Source/GameClient/GUI/GameWindowTransitionsStyles.cpp Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp - Source/GameClient/GUI/GUICallbacks/ExtendedMessageBox.cpp +# Source/GameClient/GUI/GUICallbacks/ExtendedMessageBox.cpp Source/GameClient/GUI/GUICallbacks/GeneralsExpPoints.cpp Source/GameClient/GUI/GUICallbacks/IMECandidate.cpp Source/GameClient/GUI/GUICallbacks/InGameChat.cpp @@ -735,7 +735,7 @@ set(GAMEENGINE_SRC Source/GameClient/GUI/GUICallbacks/Menus/WOLQuickMatchMenu.cpp Source/GameClient/GUI/GUICallbacks/Menus/WOLStatusMenu.cpp Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp - Source/GameClient/GUI/GUICallbacks/MessageBox.cpp +# Source/GameClient/GUI/GUICallbacks/MessageBox.cpp Source/GameClient/GUI/GUICallbacks/ReplayControls.cpp # Source/GameClient/GUI/HeaderTemplate.cpp # Source/GameClient/GUI/IMEManager.cpp @@ -755,7 +755,7 @@ set(GAMEENGINE_SRC Source/GameClient/MessageStream/CommandXlat.cpp Source/GameClient/MessageStream/GUICommandTranslator.cpp Source/GameClient/MessageStream/HintSpy.cpp - Source/GameClient/MessageStream/HotKey.cpp +# Source/GameClient/MessageStream/HotKey.cpp Source/GameClient/MessageStream/LookAtXlat.cpp Source/GameClient/MessageStream/MetaEvent.cpp Source/GameClient/MessageStream/PlaceEventTranslator.cpp diff --git a/Generals/Code/GameEngine/Include/GameClient/AnimateWindowManager.h b/Generals/Code/GameEngine/Include/GameClient/AnimateWindowManager.h deleted file mode 100644 index aad9e80b7a2..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, ICoord2D curPos, ICoord2D restPos, Coord2D vel, UnsignedInt startTime, UnsignedInt endTime); - - ICoord2D getStartPos(); ///< Get the Start Position 2D coord - ICoord2D 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( ICoord2D 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) - ICoord2D 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 ICoord2D 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( ICoord2D 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/ExtendedMessageBox.h b/Generals/Code/GameEngine/Include/GameClient/ExtendedMessageBox.h deleted file mode 100644 index 25c13a718f8..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/ExtendedMessageBox.h +++ /dev/null @@ -1,69 +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: ExtendedMessageBox.h ///////////////////////////////////////////////////////////////////// -// Author: Matt Campbell, January 2003 -// Description: We go quiet in 1 day, gold in 15. Poor time to rewrite message boxes, so -// we get this file instead. Phooey. -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "GameClient/GameWindowManager.h" - -// return codes for message box callbacks -enum MessageBoxReturnType CPP_11(: Int) { - MB_RETURN_CLOSE, - MB_RETURN_KEEPOPEN -}; - -typedef MessageBoxReturnType (* MessageBoxFunc)( void *userData ); - -// WindowExMessageBoxData --------------------------------------------------------- -/** Data attached to each extended Message box window */ -//----------------------------------------------------------------------------- -struct WindowExMessageBoxData -{ - MessageBoxFunc yesCallback; ///. -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (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/Include/GameClient/HotKey.h b/Generals/Code/GameEngine/Include/GameClient/HotKey.h deleted file mode 100644 index 3c9cade4eef..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/HotKey.h +++ /dev/null @@ -1,112 +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: HotKey.h ///////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Electronic Arts Pacific. -// -// Confidential Information -// Copyright (C) 2002 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// created: Sep 2002 -// -// Filename: HotKey.h -// -// author: Chris Huybregts -// -// purpose: -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -//----------------------------------------------------------------------------- -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// USER INCLUDES ////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -#include "Common/SubsystemInterface.h" -#include "Common/MessageStream.h" -//----------------------------------------------------------------------------- -// FORWARD REFERENCES ///////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -class AsciiString; -class GameWindow; -//----------------------------------------------------------------------------- -// TYPE DEFINES /////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -class HotKeyTranslator : public GameMessageTranslator -{ -public: - virtual GameMessageDisposition translateGameMessage(const GameMessage *msg) override; - virtual ~HotKeyTranslator() override { } -}; - -//----------------------------------------------------------------------------- -class HotKey -{ -public: - HotKey(); - GameWindow *m_win; - AsciiString m_key; - // we may need a checkmark system. -}; - -//----------------------------------------------------------------------------- -class HotKeyManager : public SubsystemInterface -{ -public: - HotKeyManager(); - virtual ~HotKeyManager() override; - // Inherited from subsystem interface ----------------------------------------------------------- - virtual void init() override; ///< Initialize the Hotkey system - virtual void update() override {} ///< A No-op for us - virtual void reset() override; ///< Reset - //----------------------------------------------------------------------------------------------- - - void addHotKey( GameWindow *win, const AsciiString& key); - Bool executeHotKey( const AsciiString& key); // called fromt eh HotKeyTranslator - - AsciiString searchHotKey( const AsciiString& label); - AsciiString searchHotKey( const UnicodeString& uStr ); - -private: - typedef std::map HotKeyMap; - HotKeyMap m_hotKeyMap; -}; -extern HotKeyManager *TheHotKeyManager; -//----------------------------------------------------------------------------- -// INLINING /////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// EXTERNALS ////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- diff --git a/Generals/Code/GameEngine/Include/GameClient/MessageBox.h b/Generals/Code/GameEngine/Include/GameClient/MessageBox.h deleted file mode 100644 index cf5951e0990..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/MessageBox.h +++ /dev/null @@ -1,46 +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: MessageBox.h ///////////////////////////////////////////////////////////////////////////// -// Author: Chris Huybregts, November 2001 -// Description: Message Box file containing user aliases -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "GameClient/GameWindowManager.h" - -GameWindow *MessageBoxYesNo(UnicodeString titleString,UnicodeString bodyString,GameWinMsgBoxFunc yesCallback,GameWinMsgBoxFunc noCallback); ///< convenience function for displaying a Message box with Yes and No buttons -GameWindow *QuitMessageBoxYesNo(UnicodeString titleString,UnicodeString bodyString,GameWinMsgBoxFunc yesCallback,GameWinMsgBoxFunc noCallback); ///< convenience function for displaying a Message box with Yes and No buttons - - -GameWindow *MessageBoxYesNoCancel(UnicodeString titleString,UnicodeString bodyString, GameWinMsgBoxFunc yesCallback, GameWinMsgBoxFunc noCallback, GameWinMsgBoxFunc cancelCallback);///< convenience function for displaying a Message box with Yes,No and Cancel buttons - - -GameWindow *MessageBoxOkCancel(UnicodeString titleString,UnicodeString bodyString,GameWinMsgBoxFunc okCallback,GameWinMsgBoxFunc cancelCallback);///< convenience function for displaying a Message box with Ok and Cancel buttons - -GameWindow *MessageBoxOk(UnicodeString titleString,UnicodeString bodyString,GameWinMsgBoxFunc okCallback);///< convenience function for displaying a Message box with Ok button - - -GameWindow *MessageBoxCancel(UnicodeString titleString,UnicodeString bodyString,GameWinMsgBoxFunc cancelCallback);///< convenience function for displaying a Message box with Cancel button 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 c2b73a16b11..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp +++ /dev/null @@ -1,422 +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" -//----------------------------------------------------------------------------- -// 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; - 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, - ICoord2D 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; -} - -void AnimateWindowManager::update() -{ - - 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)) - m_needsUpdate = TRUE; - } - else - { - if(!processAnim->updateAnimateWindow(animWin)) - 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); - } - else - { - if(processAnim) - processAnim->updateAnimateWindow(animWin); - } - 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/GUICallbacks/ExtendedMessageBox.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ExtendedMessageBox.cpp deleted file mode 100644 index ee2000cabae..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ExtendedMessageBox.cpp +++ /dev/null @@ -1,308 +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: ExtendedMessageBox.cpp /////////////////////////////////////////////////////////////////// -// Author: Matt Campbell, January 2003 -// Description: We go quiet in 1 day, gold in 15. Poor time to rewrite message boxes, so -// we get this file instead. Phooey. -/////////////////////////////////////////////////////////////////////////////////////////////////// - -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// - -// USER INCLUDES ////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "Common/GameEngine.h" -#include "Common/NameKeyGenerator.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GadgetStaticText.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/ExtendedMessageBox.h" - -WindowMsgHandledType ExtendedMessageBoxSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ); - -//------------------------------------------------------------------------------------------------- -/** Create an extended Modal Message Box */ -//------------------------------------------------------------------------------------------------- -static GameWindow *gogoExMessageBox(Int x, Int y, Int width, Int height, UnsignedShort buttonFlags, - UnicodeString titleString, UnicodeString bodyString, void *userData, - MessageBoxFunc yesCallback, - MessageBoxFunc noCallback, - MessageBoxFunc okCallback, - MessageBoxFunc cancelCallback ) -{ - // first check to make sure we have some buttons to display - if(buttonFlags == 0 ) - { - return nullptr; - } - - GameWindow *parent = TheWindowManager->winCreateFromScript( "Menus/MessageBox.wnd" ); - TheWindowManager->winSetModal( parent ); - TheWindowManager->winSetFocus( nullptr ); // make sure we lose focus from other windows even if we refuse focus ourselves - TheWindowManager->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 = TheNameKeyGenerator->nameToKey( "MessageBox.wnd:ButtonOk" ); - GameWindow *buttonOk = TheWindowManager->winGetWindowFromId(parent, buttonOkID); - buttonOk->winGetPosition(&buttonX[0], &buttonY[0]); - - NameKeyType buttonYesID = TheNameKeyGenerator->nameToKey( "MessageBox.wnd:ButtonYes" ); - GameWindow *buttonYes = TheWindowManager->winGetWindowFromId(parent, buttonYesID); - //buttonNo in the second position - NameKeyType buttonNoID = TheNameKeyGenerator->nameToKey( "MessageBox.wnd:ButtonNo" ); - GameWindow *buttonNo = TheWindowManager->winGetWindowFromId(parent, buttonNoID); - buttonNo->winGetPosition(&buttonX[1], &buttonY[1]); - - //and buttonCancel in the third - NameKeyType buttonCancelID = TheNameKeyGenerator->nameToKey( "MessageBox.wnd:ButtonCancel" ); - GameWindow *buttonCancel = TheWindowManager->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 - NameKeyType staticTextTitleID = TheNameKeyGenerator->nameToKey( "MessageBox.wnd:StaticTextTitle" ); - GameWindow *staticTextTitle = TheWindowManager->winGetWindowFromId(parent, staticTextTitleID); - GadgetStaticTextSetText(staticTextTitle,titleString); - - NameKeyType staticTextMessageID = TheNameKeyGenerator->nameToKey( "MessageBox.wnd:StaticTextMessage" ); - GameWindow *staticTextMessage = TheWindowManager->winGetWindowFromId(parent, staticTextMessageID); - GadgetStaticTextSetText(staticTextMessage,bodyString); - - // create a structure that will pass the functions to - WindowExMessageBoxData *MsgBoxCallbacks = NEW WindowExMessageBoxData; - MsgBoxCallbacks->cancelCallback = cancelCallback; - MsgBoxCallbacks->noCallback = noCallback; - MsgBoxCallbacks->okCallback = okCallback; - MsgBoxCallbacks->yesCallback = yesCallback; - MsgBoxCallbacks->userData = userData; - //pass the structure to the dialog - parent->winSetUserData( MsgBoxCallbacks ); - - parent->winSetSystemFunc(ExtendedMessageBoxSystem); - - //make sure the dialog is showing and bring it to the top - parent->winHide(FALSE); - parent->winBringToTop(); - - return parent; -} - -GameWindow *ExMessageBoxYesNo (UnicodeString titleString,UnicodeString bodyString, void *userData, - MessageBoxFunc yesCallback, MessageBoxFunc noCallback) -{ - return gogoExMessageBox(-1,-1,-1,-1,MSG_BOX_NO | MSG_BOX_YES , titleString, bodyString, userData, yesCallback, noCallback, nullptr, nullptr); -} - -GameWindow *ExMessageBoxYesNoCancel (UnicodeString titleString,UnicodeString bodyString, void *userData, - MessageBoxFunc yesCallback, MessageBoxFunc noCallback, MessageBoxFunc cancelCallback) -{ - return gogoExMessageBox(-1,-1,-1,-1,MSG_BOX_NO | MSG_BOX_YES | MSG_BOX_CANCEL , titleString, bodyString, userData, yesCallback, noCallback, nullptr, cancelCallback); -} - -GameWindow *ExMessageBoxOkCancel (UnicodeString titleString,UnicodeString bodyString, void *userData, - MessageBoxFunc okCallback, MessageBoxFunc cancelCallback) -{ - return gogoExMessageBox(-1,-1,-1,-1,MSG_BOX_OK | MSG_BOX_CANCEL , titleString, bodyString, userData, nullptr, nullptr, okCallback, cancelCallback); -} - -GameWindow *ExMessageBoxOk (UnicodeString titleString,UnicodeString bodyString, void *userData, - MessageBoxFunc okCallback) -{ - return gogoExMessageBox(-1,-1,-1,-1,MSG_BOX_OK, titleString, bodyString, userData, nullptr, nullptr, okCallback, nullptr); -} - -GameWindow *ExMessageBoxCancel (UnicodeString titleString,UnicodeString bodyString, void *userData, - MessageBoxFunc cancelCallback) -{ - return gogoExMessageBox(-1,-1,-1,-1, MSG_BOX_CANCEL, titleString, bodyString, userData, nullptr, nullptr, nullptr, cancelCallback); -} - - - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// - - - -//------------------------------------------------------------------------------------------------- -/** Message Box window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType ExtendedMessageBoxSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - - - switch( msg ) - { - - //--------------------------------------------------------------------------------------------- - case GWM_DESTROY: - { - delete (WindowExMessageBoxData *)window->winGetUserData(); - window->winSetUserData( nullptr ); - break; - - } - - // -------------------------------------------------------------------------------------------- - case GWM_INPUT_FOCUS: - { - - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - break; - - } - - //--------------------------------------------------------------------------------------------- - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - static NameKeyType buttonOkID = TheNameKeyGenerator->nameToKey( "MessageBox.wnd:ButtonOk" ); - static NameKeyType buttonYesID = TheNameKeyGenerator->nameToKey( "MessageBox.wnd:ButtonYes" ); - static NameKeyType buttonNoID = TheNameKeyGenerator->nameToKey( "MessageBox.wnd:ButtonNo" ); - static NameKeyType buttonCancelID = TheNameKeyGenerator->nameToKey( "MessageBox.wnd:ButtonCancel" ); - WindowExMessageBoxData *MsgBoxCallbacks = (WindowExMessageBoxData *)window->winGetUserData(); - - MessageBoxReturnType ret = MB_RETURN_CLOSE; - - if( controlID == buttonOkID ) - { - if (MsgBoxCallbacks->okCallback) - ret = MsgBoxCallbacks->okCallback(MsgBoxCallbacks->userData); - } - else if( controlID == buttonYesID ) - { - if (MsgBoxCallbacks->yesCallback) - ret = MsgBoxCallbacks->yesCallback(MsgBoxCallbacks->userData); - } - else if( controlID == buttonNoID ) - { - if (MsgBoxCallbacks->noCallback) - ret = MsgBoxCallbacks->noCallback(MsgBoxCallbacks->userData); - } - else if( controlID == buttonCancelID ) - { - if (MsgBoxCallbacks->cancelCallback) - ret = MsgBoxCallbacks->cancelCallback(MsgBoxCallbacks->userData); - } - - if (ret == MB_RETURN_CLOSE) - TheWindowManager->winDestroy(window); - - break; - - } - - //--------------------------------------------------------------------------------------------- - default: - return MSG_IGNORED; - - } - - return MSG_HANDLED; - -} diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/MessageBox.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/MessageBox.cpp deleted file mode 100644 index 82518dd1b99..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/MessageBox.cpp +++ /dev/null @@ -1,265 +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: MessageBox.cpp ///////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: MessageBox.cpp -// -// Created: Chris Huybregts, June 2001 -// -// Desc: the Message Box control -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// - -// USER INCLUDES ////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "Common/GameEngine.h" -#include "Common/NameKeyGenerator.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/MessageBox.h" - - -GameWindow *MessageBoxYesNo(UnicodeString titleString,UnicodeString bodyString,GameWinMsgBoxFunc yesCallback,GameWinMsgBoxFunc noCallback) ///< convenience function for displaying a Message box with Yes and No buttons -{ - return TheWindowManager->gogoMessageBox(-1,-1,-1,-1,MSG_BOX_NO | MSG_BOX_YES , titleString, bodyString, yesCallback, noCallback, nullptr, nullptr); -} -GameWindow *QuitMessageBoxYesNo(UnicodeString titleString,UnicodeString bodyString,GameWinMsgBoxFunc yesCallback,GameWinMsgBoxFunc noCallback) ///< convenience function for displaying a Message box with Yes and No buttons -{ - return TheWindowManager->gogoMessageBox(-1,-1,-1,-1,MSG_BOX_NO | MSG_BOX_YES , titleString, bodyString, yesCallback, noCallback, nullptr, nullptr, TRUE); -} - - -GameWindow *MessageBoxYesNoCancel(UnicodeString titleString,UnicodeString bodyString, GameWinMsgBoxFunc yesCallback, GameWinMsgBoxFunc noCallback, GameWinMsgBoxFunc cancelCallback)///< convenience function for displaying a Message box with Yes,No and Cancel buttons -{ - return TheWindowManager->gogoMessageBox(-1,-1,-1,-1,MSG_BOX_NO | MSG_BOX_YES | MSG_BOX_CANCEL , titleString, bodyString, yesCallback, noCallback, nullptr, cancelCallback); -} - - -GameWindow *MessageBoxOkCancel(UnicodeString titleString,UnicodeString bodyString,GameWinMsgBoxFunc okCallback,GameWinMsgBoxFunc cancelCallback)///< convenience function for displaying a Message box with Ok and Cancel buttons -{ - return TheWindowManager->gogoMessageBox(-1,-1,-1,-1,MSG_BOX_OK | MSG_BOX_CANCEL , titleString, bodyString, nullptr, nullptr, okCallback, cancelCallback); -} - -GameWindow *MessageBoxOk(UnicodeString titleString,UnicodeString bodyString,GameWinMsgBoxFunc okCallback)///< convenience function for displaying a Message box with Ok button -{ - return TheWindowManager->gogoMessageBox(-1,-1,-1,-1,MSG_BOX_OK, titleString, bodyString, nullptr, nullptr, okCallback, nullptr); -} - - -GameWindow *MessageBoxCancel(UnicodeString titleString,UnicodeString bodyString,GameWinMsgBoxFunc cancelCallback)///< convenience function for displaying a Message box with Cancel button -{ - return TheWindowManager->gogoMessageBox(-1,-1,-1,-1, MSG_BOX_CANCEL, titleString, bodyString, nullptr, nullptr, nullptr, cancelCallback); -} - - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// - - - -//------------------------------------------------------------------------------------------------- -/** Message Box window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType MessageBoxSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - - - switch( msg ) - { - - //--------------------------------------------------------------------------------------------- - case GWM_DESTROY: - { - delete (WindowMessageBoxData *)window->winGetUserData(); - window->winSetUserData( nullptr ); - break; - - } - - // -------------------------------------------------------------------------------------------- - case GWM_INPUT_FOCUS: - { - - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - break; - - } - - //--------------------------------------------------------------------------------------------- - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - static NameKeyType buttonOkID = TheNameKeyGenerator->nameToKey( "MessageBox.wnd:ButtonOk" ); - static NameKeyType buttonYesID = TheNameKeyGenerator->nameToKey( "MessageBox.wnd:ButtonYes" ); - static NameKeyType buttonNoID = TheNameKeyGenerator->nameToKey( "MessageBox.wnd:ButtonNo" ); - static NameKeyType buttonCancelID = TheNameKeyGenerator->nameToKey( "MessageBox.wnd:ButtonCancel" ); - WindowMessageBoxData *MsgBoxCallbacks = (WindowMessageBoxData *)window->winGetUserData(); - - if( controlID == buttonOkID ) - { - //simple enough,if we have a callback, call it, if not, then just destroy the window - if (MsgBoxCallbacks->okCallback) - MsgBoxCallbacks->okCallback(); - - TheWindowManager->winDestroy(window); - - } - else if( controlID == buttonYesID ) - { - if (MsgBoxCallbacks->yesCallback) - MsgBoxCallbacks->yesCallback(); - TheWindowManager->winDestroy(window); - } - else if( controlID == buttonNoID ) - { - if (MsgBoxCallbacks->noCallback) - MsgBoxCallbacks->noCallback(); - TheWindowManager->winDestroy(window); - } - else if( controlID == buttonCancelID ) - { - if (MsgBoxCallbacks->cancelCallback) - MsgBoxCallbacks->cancelCallback(); - TheWindowManager->winDestroy(window); - } - - break; - - } - - //--------------------------------------------------------------------------------------------- - default: - return MSG_IGNORED; - - } - - return MSG_HANDLED; - -} -//------------------------------------------------------------------------------------------------- -/** Message Box window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType QuitMessageBoxSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - - - switch( msg ) - { - - //--------------------------------------------------------------------------------------------- - case GWM_DESTROY: - { - delete (WindowMessageBoxData *)window->winGetUserData(); - window->winSetUserData( nullptr ); - break; - - } - - // -------------------------------------------------------------------------------------------- - case GWM_INPUT_FOCUS: - { - - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - break; - - } - - //--------------------------------------------------------------------------------------------- - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - static NameKeyType buttonOkID = TheNameKeyGenerator->nameToKey( "QuitMessageBox.wnd:ButtonOk" ); - static NameKeyType buttonYesID = TheNameKeyGenerator->nameToKey( "QuitMessageBox.wnd:ButtonYes" ); - static NameKeyType buttonNoID = TheNameKeyGenerator->nameToKey( "QuitMessageBox.wnd:ButtonNo" ); - static NameKeyType buttonCancelID = TheNameKeyGenerator->nameToKey( "QuitMessageBox.wnd:ButtonCancel" ); - WindowMessageBoxData *MsgBoxCallbacks = (WindowMessageBoxData *)window->winGetUserData(); - - if( controlID == buttonOkID ) - { - //simple enough,if we have a callback, call it, if not, then just destroy the window - if (MsgBoxCallbacks->okCallback) - MsgBoxCallbacks->okCallback(); - - TheWindowManager->winDestroy(window); - - } - else if( controlID == buttonYesID ) - { - if (MsgBoxCallbacks->yesCallback) - MsgBoxCallbacks->yesCallback(); - TheWindowManager->winDestroy(window); - } - else if( controlID == buttonNoID ) - { - if (MsgBoxCallbacks->noCallback) - MsgBoxCallbacks->noCallback(); - TheWindowManager->winDestroy(window); - } - else if( controlID == buttonCancelID ) - { - if (MsgBoxCallbacks->cancelCallback) - MsgBoxCallbacks->cancelCallback(); - TheWindowManager->winDestroy(window); - } - - break; - - } - - //--------------------------------------------------------------------------------------------- - default: - return MSG_IGNORED; - - } - - return MSG_HANDLED; - -} 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/GameClientDispatch.cpp b/Generals/Code/GameEngine/Source/GameClient/GameClientDispatch.cpp deleted file mode 100644 index fb657816171..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GameClientDispatch.cpp +++ /dev/null @@ -1,56 +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: .cpp ///////////////////////////////////////////////////////////////////////////////////// -// Author: Colin Day -// Description: Game Client message dispatcher -/////////////////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "Common/MessageStream.h" -#include "GameClient/GameClient.h" - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -/** The Client message dispatcher, this is the last "translator" on the message - * stream before the messages go to the network for processing. It gives - * the client itself the opportunity to respond to any messages on the stream - * or create new ones to pass along to the network and logic */ -GameMessageDisposition GameClientMessageDispatcher::translateGameMessage(const GameMessage *msg) -{ - if (msg->getType() >= GameMessage::MSG_BEGIN_NETWORK_MESSAGES && msg->getType() <= GameMessage::MSG_END_NETWORK_MESSAGES) - return KEEP_MESSAGE; - if (msg->getType() == GameMessage::MSG_NEW_GAME || msg->getType() == GameMessage::MSG_CLEAR_GAME_DATA) - return KEEP_MESSAGE; - - if (msg->getType() == GameMessage::MSG_FRAME_TICK) - return KEEP_MESSAGE; - - //DEBUG_LOG(("GameClientMessageDispatcher::translateGameMessage() - eating a %s on frame %d", - //((GameMessage *)msg)->getCommandAsString(), TheGameClient->getFrame())); - - return DESTROY_MESSAGE; -} diff --git a/Generals/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp b/Generals/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp deleted file mode 100644 index 63af29ea6fd..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp +++ /dev/null @@ -1,231 +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: HotKey.cpp ///////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Electronic Arts Pacific. -// -// Confidential Information -// Copyright (C) 2002 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// created: Sep 2002 -// -// Filename: HotKey.cpp -// -// author: Chris Huybregts -// -// purpose: -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -//----------------------------------------------------------------------------- -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -//----------------------------------------------------------------------------- -// USER INCLUDES ////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -#include "GameClient/HotKey.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/MetaEvent.h" -#include "GameClient/GameWindow.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/Keyboard.h" -#include "GameClient/GameText.h" -#include "Common/AudioEventRTS.h" -//----------------------------------------------------------------------------- -// DEFINES //////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// PUBLIC FUNCTIONS /////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -GameMessageDisposition HotKeyTranslator::translateGameMessage(const GameMessage *msg) -{ - GameMessageDisposition disp = KEEP_MESSAGE; - GameMessage::Type t = msg->getType(); - - if ( t == GameMessage::MSG_RAW_KEY_UP) - { - - //char key = msg->getArgument(0)->integer; - Int keyState = msg->getArgument(1)->integer; - - // for our purposes here, we don't care to distinguish between right and left keys, - // so just fudge a little to simplify things. - Int newModState = 0; - - if( keyState & KEY_STATE_CONTROL ) - { - newModState |= CTRL; - } - - if( keyState & KEY_STATE_SHIFT ) - { - newModState |= SHIFT; - } - - if( keyState & KEY_STATE_ALT ) - { - newModState |= ALT; - } - if(newModState != 0) - return disp; - WideChar key = TheKeyboard->getPrintableKey((KeyDefType)msg->getArgument(0)->integer, 0); - UnicodeString uKey; - uKey.concat(key); - AsciiString aKey; - aKey.translate(uKey); - if(TheHotKeyManager && TheHotKeyManager->executeHotKey(aKey)) - disp = DESTROY_MESSAGE; - } - return disp; -} - -//----------------------------------------------------------------------------- -HotKey::HotKey() -{ - m_win = nullptr; - m_key.clear(); -} - -//----------------------------------------------------------------------------- -HotKeyManager::HotKeyManager() -{ - -} - -//----------------------------------------------------------------------------- -HotKeyManager::~HotKeyManager() -{ - m_hotKeyMap.clear(); -} - -//----------------------------------------------------------------------------- -void HotKeyManager::init() -{ - m_hotKeyMap.clear(); -} - -//----------------------------------------------------------------------------- -void HotKeyManager::reset() -{ - m_hotKeyMap.clear(); -} - -//----------------------------------------------------------------------------- -void HotKeyManager::addHotKey( GameWindow *win, const AsciiString& keyIn) -{ - AsciiString key = keyIn; - key.toLower(); - HotKeyMap::iterator it = m_hotKeyMap.find(key); - if( it != m_hotKeyMap.end() ) - { - DEBUG_CRASH(("Hotkey %s is already mapped to window %s, current window is %s", key.str(), it->second.m_win->winGetInstanceData()->m_decoratedNameString.str(), win->winGetInstanceData()->m_decoratedNameString.str())); - return; - } - HotKey newHK; - newHK.m_key.set(key); - newHK.m_win = win; - m_hotKeyMap[key] = newHK; -} - -//----------------------------------------------------------------------------- -Bool HotKeyManager::executeHotKey( const AsciiString& keyIn ) -{ - AsciiString key = keyIn; - key.toLower(); - HotKeyMap::iterator it = m_hotKeyMap.find(key); - if( it == m_hotKeyMap.end() ) - return FALSE; - GameWindow *win = it->second.m_win; - if( !win ) - return FALSE; - if( !BitIsSet( win->winGetStatus(), WIN_STATUS_HIDDEN ) ) - { - if( BitIsSet( win->winGetStatus(), WIN_STATUS_ENABLED ) ) - { - TheWindowManager->winSendSystemMsg( win->winGetParent(), GBM_SELECTED, (WindowMsgData)win, win->winGetWindowId() ); - - // here we make the same click sound that the GUI uses when you click a button - AudioEventRTS buttonClick("GUIClick"); - - if( TheAudio ) - { - TheAudio->addAudioEvent( &buttonClick ); - } - return TRUE; - } - - AudioEventRTS disabledClick( "GUIClickDisabled" ); - if( TheAudio ) - { - TheAudio->addAudioEvent( &disabledClick ); - } - } - return FALSE; -} - -//----------------------------------------------------------------------------- -AsciiString HotKeyManager::searchHotKey( const AsciiString& label) -{ - return searchHotKey(TheGameText->fetch(label)); -} - -//----------------------------------------------------------------------------- -AsciiString HotKeyManager::searchHotKey( const UnicodeString& uStr ) -{ - if(uStr.isEmpty()) - return AsciiString::TheEmptyString; - - const WideChar *marker = (const WideChar *)uStr.str(); - while (marker && *marker) - { - if (*marker == L'&') - { - // found a '&' - now look for the next char - UnicodeString tmp = UnicodeString::TheEmptyString; - tmp.concat(*(marker+1)); - AsciiString retStr; - retStr.translate(tmp); - return retStr; - } - marker++; - } - return AsciiString::TheEmptyString; -} - -//----------------------------------------------------------------------------- -HotKeyManager *TheHotKeyManager = nullptr; - -//----------------------------------------------------------------------------- -// PRIVATE FUNCTIONS ////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - diff --git a/GeneralsMD/Code/GameEngine/CMakeLists.txt b/GeneralsMD/Code/GameEngine/CMakeLists.txt index e397fe32d5b..1f4ce0de287 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 @@ -157,7 +157,7 @@ set(GAMEENGINE_SRC # Include/GameClient/DrawGroupInfo.h Include/GameClient/EstablishConnectionsMenu.h Include/GameClient/Eva.h - Include/GameClient/ExtendedMessageBox.h +# Include/GameClient/ExtendedMessageBox.h Include/GameClient/FontDesc.h # Include/GameClient/FXList.h Include/GameClient/Gadget.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 @@ -186,7 +186,7 @@ set(GAMEENGINE_SRC Include/GameClient/GUICommandTranslator.h # Include/GameClient/HeaderTemplate.h Include/GameClient/HintSpy.h - Include/GameClient/HotKey.h +# Include/GameClient/HotKey.h # Include/GameClient/Image.h # Include/GameClient/IMEManager.h Include/GameClient/InGameUI.h @@ -197,7 +197,7 @@ set(GAMEENGINE_SRC # Include/GameClient/LoadScreen.h Include/GameClient/LookAtXlat.h # Include/GameClient/MapUtil.h - Include/GameClient/MessageBox.h +# Include/GameClient/MessageBox.h Include/GameClient/MetaEvent.h # Include/GameClient/Module/AnimatedParticleSysBoneClientUpdate.h # Include/GameClient/Module/BeaconClientUpdate.h @@ -690,11 +690,11 @@ set(GAMEENGINE_SRC Source/GameClient/Eva.cpp # Source/GameClient/FXList.cpp Source/GameClient/GameClient.cpp - Source/GameClient/GameClientDispatch.cpp +# Source/GameClient/GameClientDispatch.cpp # 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,14 +724,14 @@ 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/GameWindowManager.cpp Source/GameClient/GUI/GameWindowManagerScript.cpp # Source/GameClient/GUI/GameWindowTransitions.cpp Source/GameClient/GUI/GameWindowTransitionsStyles.cpp Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp - Source/GameClient/GUI/GUICallbacks/ExtendedMessageBox.cpp +# Source/GameClient/GUI/GUICallbacks/ExtendedMessageBox.cpp Source/GameClient/GUI/GUICallbacks/GeneralsExpPoints.cpp Source/GameClient/GUI/GUICallbacks/IMECandidate.cpp Source/GameClient/GUI/GUICallbacks/InGameChat.cpp @@ -777,7 +777,7 @@ set(GAMEENGINE_SRC Source/GameClient/GUI/GUICallbacks/Menus/WOLQuickMatchMenu.cpp Source/GameClient/GUI/GUICallbacks/Menus/WOLStatusMenu.cpp Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp - Source/GameClient/GUI/GUICallbacks/MessageBox.cpp +# Source/GameClient/GUI/GUICallbacks/MessageBox.cpp Source/GameClient/GUI/GUICallbacks/ReplayControls.cpp # Source/GameClient/GUI/HeaderTemplate.cpp # Source/GameClient/GUI/IMEManager.cpp @@ -797,7 +797,7 @@ set(GAMEENGINE_SRC Source/GameClient/MessageStream/CommandXlat.cpp Source/GameClient/MessageStream/GUICommandTranslator.cpp Source/GameClient/MessageStream/HintSpy.cpp - Source/GameClient/MessageStream/HotKey.cpp +# Source/GameClient/MessageStream/HotKey.cpp Source/GameClient/MessageStream/LookAtXlat.cpp Source/GameClient/MessageStream/MetaEvent.cpp Source/GameClient/MessageStream/PlaceEventTranslator.cpp diff --git a/scripts/cpp/unify_move_files.py b/scripts/cpp/unify_move_files.py index 1b03fd19f12..d7c9a72fb88 100644 --- a/scripts/cpp/unify_move_files.py +++ b/scripts/cpp/unify_move_files.py @@ -492,6 +492,19 @@ def main(): #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/Drawable/Update/SwayClientUpdate.cpp", Game.CORE, "GameEngine/Source/GameClient/Drawable/Update/SwayClientUpdate.cpp") #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/Module/SwayClientUpdate.h", Game.CORE, "GameEngine/Include/GameClient/Module/SwayClientUpdate.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp", Game.CORE, "GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/AnimateWindowManager.h", Game.CORE, "GameEngine/Include/GameClient/AnimateWindowManager.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GUI/GameWindowManager.cpp", Game.CORE, "GameEngine/Source/GameClient/GUI/GameWindowManager.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/GameWindowManager.h", Game.CORE, "GameEngine/Include/GameClient/GameWindowManager.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GUI/GUICallbacks/MessageBox.cpp", Game.CORE, "GameEngine/Source/GameClient/GUI/GUICallbacks/MessageBox.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/MessageBox.h", Game.CORE, "GameEngine/Include/GameClient/MessageBox.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GUI/GUICallbacks/ExtendedMessageBox.cpp", Game.CORE, "GameEngine/Source/GameClient/GUI/GUICallbacks/ExtendedMessageBox.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/ExtendedMessageBox.h", Game.CORE, "GameEngine/Include/GameClient/ExtendedMessageBox.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GameClientDispatch.cpp", Game.CORE, "GameEngine/Source/GameClient/GameClientDispatch.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/MessageStream/HotKey.cpp", Game.CORE, "GameEngine/Source/GameClient/MessageStream/HotKey.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/HotKey.h", Game.CORE, "GameEngine/Include/GameClient/HotKey.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/GameWindowID.h", Game.CORE, "GameEngine/Include/GameClient/GameWindowID.h") + return