Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement parts of InGameUI #1056

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/game/client/globallanguage.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ class GlobalLanguage : public SubsystemInterface
const FontDesc &Debug_Display_Font() const { return m_nativeDebugDisplayFont; }
const FontDesc &Default_Window_Font() const { return m_defaultWindowFont; }
const FontDesc &Default_Display_String_Font() const { return m_defaultDisplayStringFont; }
const FontDesc &Drawable_Caption_Font() const { return m_drawableCaptionFont; }
const FontDesc &Message_Font() const { return m_messageFont; }
const FontDesc &Military_Caption_Title_Font() const { return m_militaryCaptionTitleFont; }
const FontDesc &Military_Caption_Font() const { return m_militaryCaptionFont; }
const FontDesc &Superweapon_Countdown_Normal_Font() const { return m_superweaponCountdownNormalFont; }
const FontDesc &Superweapon_Countdown_Ready_Font() const { return m_superweaponCountdownReadyFont; }
const FontDesc &Named_Timer_Countdown_Normal_Font() const { return m_namedTimerCountdownNormalFont; }
const FontDesc &Named_Timer_Countdown_Ready_Font() const { return m_namedTimerCountdownReadyFont; }

static void Parse_Language_Definition(INI *ini);
static void Parse_Font_Filename(INI *ini, void *formal, void *store, void const *user_data);
Expand Down
1,712 changes: 1,700 additions & 12 deletions src/game/client/ingameui.cpp

Large diffs are not rendered by default.

42 changes: 23 additions & 19 deletions src/game/client/ingameui.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,38 +103,38 @@ class SuperweaponInfo : public MemoryPoolObject

public:
SuperweaponInfo(ObjectID object_id,
unsigned int unk1,
unsigned int countdown_seconds,
bool hidden,
bool unk2,
bool unk3,
bool unk4,
const Utf8String *font_name,
bool is_missing_science,
bool is_ready,
bool has_played_sound,
const Utf8String &font_name,
int font_size,
bool font_bold,
int color,
const SpecialPowerTemplate *power_template);
~SuperweaponInfo();
void Set_Font(const Utf8String *name, int size, bool bold);
void Set_Text(Utf16String *name, Utf16String *time);
void Set_Font(const Utf8String &name, int size, bool bold);
void Set_Text(Utf16String &name, Utf16String &time);
void Draw_Name(int x, int y, int color, int border_color);
void Draw_Time(int x, int y, int color, int border_color);
float Get_Height() const;

SpecialPowerTemplate *Get_Special_Power_Template() const { return m_powerTemplate; }
const SpecialPowerTemplate *Get_Special_Power_Template() const { return m_powerTemplate; }

private:
DisplayString *m_name;
DisplayString *m_time;
int m_color;
SpecialPowerTemplate *m_powerTemplate;
Utf8String m_unk1;
const SpecialPowerTemplate *m_powerTemplate;
Utf8String m_unk;
ObjectID m_objectID;
unsigned int m_unk2;
unsigned int m_countdownSeconds;
bool m_hidden;
bool m_unk3;
bool m_unk4;
bool m_unk5;
bool m_unk6;
bool m_isMissingScience;
bool m_isReady;
bool m_hasPlayedSound;
bool m_refreshCountdown;
friend class InGameUI;
};

Expand Down Expand Up @@ -276,6 +276,9 @@ class InGameUI : public SubsystemInterface, public SnapShot
virtual void Reset() override;
virtual void Update() override;
virtual void Draw() override = 0;
virtual void CRC_Snapshot(Xfer *xfer) override;
virtual void Xfer_Snapshot(Xfer *xfer) override;
virtual void Load_Post_Process() override;
virtual void Popup_Message(
Utf8String const &message, int width_percent, int height_percent, int width, bool pause, bool pause_music);
virtual void Popup_Message(Utf8String const &message,
Expand Down Expand Up @@ -396,7 +399,6 @@ class InGameUI : public SubsystemInterface, public SnapShot

void Add_World_Animation(
Anim2DTemplate *anim, const Coord3D *pos, WorldAnimationOptions options, float time, float z_rise);
bool Are_Selected_Objects_Controllable();
void Set_Mouse_Cursor(MouseCursor cursor);
SuperweaponInfo *Find_SW_Info(
int player_index, Utf8String const &power_name, ObjectID id, SpecialPowerTemplate const *power_template);
Expand Down Expand Up @@ -511,9 +513,9 @@ class InGameUI : public SubsystemInterface, public SnapShot
bool m_displayedMaxWarning;
MoveHintStruct m_moveHint[MAX_MOVE_HINTS];
int m_nextMoveHint;
CommandButton *m_pendingGUICommand;
const CommandButton *m_pendingGUICommand;
BuildProgress m_buildProgress[MAX_BUILD_PROGRESS];
CommandButton *m_pendingPlaceType;
const ThingTemplate *m_pendingPlaceType;
ObjectID m_pendingPlaceSourceObjectID;
#ifndef GAME_DEBUG_STRUCTS
bool m_preventLeftClickDeselectionInAlternateMouseModeForOneClick; // not 100% identified yet
Expand Down Expand Up @@ -569,7 +571,7 @@ class InGameUI : public SubsystemInterface, public SnapShot
bool m_isSelecting;
MouseMode m_mouseMode;
MouseCursor m_mouseCursor; // not 100% identified yet
ObjectID m_mousedOverObjectID;
DrawableID m_mousedOverObjectID;
Coord2D m_scrollAmt;
bool m_isQuitMenuVisible;
bool m_messagesOn;
Expand Down Expand Up @@ -627,6 +629,8 @@ void Toggle_Replay_Controls();

#ifdef GAME_DLL
extern InGameUI *&g_theInGameUI;
extern GameWindow *&g_replayWindow;
#else
extern InGameUI *g_theInGameUI;
extern GameWindow *g_replayWindow;
#endif
2 changes: 1 addition & 1 deletion src/game/client/messagestream/lookatxlat.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LookAtTranslator : public GameMessageTranslator
public:
virtual GameMessageDisposition Translate_Game_Message(const GameMessage *msg) override;
virtual ~LookAtTranslator() override;
const ICoord2D *Get_RMB_Scroll_Anchor();
virtual const ICoord2D *Get_RMB_Scroll_Anchor();
bool Has_Mouse_Moved_Recently();

private:
Expand Down
4 changes: 2 additions & 2 deletions src/game/client/radiusdecal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ void RadiusDecal::Set_Opacity(float opacity)
}
}

void RadiusDecal::Set_Position(const Coord3D *pos)
void RadiusDecal::Set_Position(const Coord3D &pos)
{
if (m_shadow != nullptr) {
m_shadow->Set_Position(pos->x, pos->y, pos->z);
m_shadow->Set_Position(pos.x, pos.y, pos.z);
}
}
2 changes: 1 addition & 1 deletion src/game/client/radiusdecal.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class RadiusDecal
void Clear();
void Update();
void Set_Opacity(float opacity);
void Set_Position(const Coord3D *pos);
void Set_Position(const Coord3D &pos);

private:
RadiusDecalTemplate *m_template;
Expand Down
2 changes: 2 additions & 0 deletions src/game/common/gamemessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class GameMessage : public MemoryPoolObject
MSG_INVALID_GUICOMMAND_HINT = 139,
MSG_AREA_SELECTION_HINT = 140,
MSG_DO_ATTACK_OBJECT_HINT = 141,
MSG_UNK1 = 142,
MSG_DO_FORCE_ATTACK_OBJECT_HINT = 143,
MSG_DO_FORCE_ATTACK_GROUND_HINT = 144,
MSG_GET_REPAIRED_HINT = 145,
Expand All @@ -241,6 +242,7 @@ class GameMessage : public MemoryPoolObject
MSG_SNIPE_VEHICLE_HINT = 159,
MSG_DEFECTOR_HINT = 160,
MSG_SET_RALLY_POINT_HINT = 161,
MSG_UNK2 = 162,
MSG_DO_SALVAGE_HINT = 163,
MSG_DO_INVALID_HINT = 164,
MSG_DO_ATTACK_OBJECT_AFTER_MOVING_HINT = 165,
Expand Down
2 changes: 1 addition & 1 deletion src/game/common/ini/ini.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const BlockParse TheTypeTable[] = {
{"EvaEvent", HOOK_BLOCK(0x00512BE0) /*&INI::parseEvaEvent*/},
{"FXList", &FXListStore::Parse_FXList_Definition},
{"GameData", &GlobalData::Parse_Game_Data_Definition},
{"InGameUI", HOOK_BLOCK(0x00508440) /*&INI::parseInGameUIDefinition*/},
{"InGameUI", &InGameUI::Parse_In_Game_UI_Definition},
{"Locomotor", &LocomotorStore::Parse_Locomotor_Template_Definition},
{"Language", &GlobalLanguage::Parse_Language_Definition},
{"MapCache", HOOK_BLOCK(0x00506760) /*&INI::parseMapCacheDefinition*/},
Expand Down
2 changes: 1 addition & 1 deletion src/game/common/rts/specialpower.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SpecialPowerTemplate : public Overridable
unsigned int Get_Reload_Time() const { return Get_FO()->m_reloadTime; }
ScienceType Get_Required_Science() const { return m_requiredScience; }
AcademyClassificationType Get_Academy_Classify() const { return m_academyClassify; }
float Get_Radius_Cusror_Radius() const { return Get_FO()->m_radiusCursorRadius; }
float Get_Radius_Cursor_Radius() const { return Get_FO()->m_radiusCursorRadius; }

void Set_Name_ID(Utf8String const &name, unsigned int id)
{
Expand Down
1 change: 1 addition & 0 deletions src/hooker/setupglobals_zh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ Network *&g_theNetwork = Make_Global<Network *>(PICK_ADDRESS(0x00A2B92C, 0x00E26
// ingameui.cpp
#include "ingameui.h"
InGameUI *&g_theInGameUI = Make_Global<InGameUI *>(PICK_ADDRESS(0x00A2C088, 0x00E26268));
GameWindow *&g_replayWindow = Make_Global<GameWindow *>(PICK_ADDRESS(0x00A2C08C, 0x00E2626C));

// waterrenderobj.cpp
class WaterRenderObjClass;
Expand Down
34 changes: 34 additions & 0 deletions src/hooker/setuphooks_zh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3718,6 +3718,9 @@ void Setup_Hooks()
Hook_Any(0x00489930, Left_HUD_Input);
Hook_Any(0x00489D00, Control_Bar_System);
Hook_Any(0x0048A540, Toggle_Control_Bar);
Hook_Memory(0x009DF438, Left_HUD_Input);
Hook_Memory(0x0050B307, Left_HUD_Input);
Hook_Memory(0x0050BC60, Left_HUD_Input);

// controlbarscheme.h
Hook_Any(0x005A66B0, ControlBarSchemeManager::Draw_Foreground);
Expand Down Expand Up @@ -3781,4 +3784,35 @@ void Setup_Hooks()
Hook_Any(0x00782290, W3DShadowManager::Remove_Shadow);
Hook_Any(0x007822A0, W3DShadowManager::Get_Light_Pos_World);
Hook_Any(0x007822C0, W3DShadowManager::Set_Time_Of_Day);

// ingameui.h
Hook_Any(0x00506FB0, Show_Replay_Controls);
Hook_Any(0x00506FD0, Hide_Replay_Controls);
Hook_Any(0x00506FF0, Toggle_Replay_Controls);
Hook_Any(0x005072F0, InGameUI::Xfer_Snapshot);
Hook_Any(0x00507A30, InGameUI::Find_SW_Info);
Hook_Any(0x00508020, InGameUI::Add_Named_Timer);
Hook_Any(0x005083C0, InGameUI::Remove_Named_Timer);
Hook_Any(0x00507A80, InGameUI::Add_Superweapon);
Hook_Any(0x00507CE0, InGameUI::Remove_Superweapon);
Hook_Any(0x00507D90, InGameUI::Object_Changed_Team);
Hook_Any(0x00507F40, InGameUI::Hide_Object_Superweapon_Display_By_Script);
Hook_Any(0x00507FA0, InGameUI::Show_Object_Superweapon_Display_By_Script);
Hook_Any(0x00508000, InGameUI::Set_Superweapon_Display_Enabled_By_Script);
Hook_Any(0x00508010, InGameUI::Get_Superweapon_Display_Enabled_By_Script);
Hook_Any(0x005093A0, InGameUI::Init);
Hook_Any(0x0050A8A0, InGameUI::Reset);
Hook_Any(0x0050AC10, InGameUI::Free_Message_Resources);
Hook_Any(0x00510890, InGameUI::Clear_Popup_Message_Data);
Hook_Any(0x0050CD70, InGameUI::Post_Draw);
Hook_Any(0x0050E540, InGameUI::Are_Selected_Objects_Controllable);
Hook_Any(0x00508430, InGameUI::Show_Named_Timer_Display);
Hook_Any(0x005097E0, InGameUI::Set_Radius_Cursor);
Hook_Any(0x00509A30, InGameUI::Handle_Radius_Cursor);
Hook_Any(0x00509B10, InGameUI::Trigger_Double_Click_Attack_Move_Guard_Hint);
Hook_Any(0x0050BB10, InGameUI::Create_Command_Hint);
Hook_Any(0x0050C5F0, InGameUI::Set_GUI_Command);
Hook_Any(0x0050C6D0, InGameUI::Place_Build_Available);
Hook_Any(0x00511120, InGameUI::Recreate_Control_Bar);
Hook_Any(0x00508D50, InGameUI::Get_Field_Parse);
}
Loading