Skip to content

[Customized] Enhanced MessageDisplayInCenter #1792

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
<ClCompile Include="src\New\Entity\AttachEffectClass.cpp" />
<ClCompile Include="src\New\Type\Affiliated\TiberiumEaterTypeClass.cpp" />
<ClCompile Include="src\New\Type\AttachEffectTypeClass.cpp" />
<ClCompile Include="src\Misc\MessageColumn.cpp" />
<ClCompile Include="src\Commands\ToggleMessageList.cpp" />
<ClCompile Include="src\Commands\Commands.cpp" />
<ClCompile Include="src\Commands\DamageDisplay.cpp" />
<ClCompile Include="src\Commands\FrameByFrame.cpp" />
Expand Down Expand Up @@ -190,7 +192,6 @@
<ClCompile Include="src\Misc\Hooks.Timers.cpp" />
<ClCompile Include="src\Misc\Hooks.INIInheritance.cpp" />
<ClCompile Include="src\Misc\Hooks.Overlay.cpp" />
<ClCompile Include="src\Misc\Hooks.Message.cpp" />
<ClCompile Include="src\New\Type\Affiliated\TypeConvertGroup.cpp" />
<ClCompile Include="src\Ext\BuildingType\Hooks.Upgrade.cpp" />
<ClCompile Include="src\Phobos.COM.cpp" />
Expand Down Expand Up @@ -223,6 +224,8 @@
<ClInclude Include="src\New\Entity\AttachEffectClass.h" />
<ClInclude Include="src\New\Type\Affiliated\TiberiumEaterTypeClass.h" />
<ClInclude Include="src\New\Type\AttachEffectTypeClass.h" />
<ClInclude Include="src\Misc\MessageColumn.h" />
<ClInclude Include="src\Commands\ToggleMessageList.h" />
<ClInclude Include="src\Commands\FrameByFrame.h" />
<ClInclude Include="src\Commands\FrameStep.h" />
<ClInclude Include="src\Commands\NextIdleHarvester.h" />
Expand Down
21 changes: 16 additions & 5 deletions docs/User-Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,17 +370,23 @@ ShowTimer.Priority=0 ; integer

### Task subtitles display in the middle of the screen

![Message Display In Center](_static/images/messagedisplayincenter.png)
![Message Display In Center](_static/images/messagedisplayincenter.gif)
*Taking a campaign in [Mental Omega](https://www.mentalomega.com) as an example to display messages in center*

- Now you can set `MessageApplyHoverState` to true,to make the upper left messages not disappear while mouse hovering over the top of display area.
- You can also let task subtitles (created by trigger 11) to display directly in the middle area of the screen instead of the upper left corner, with a semi transparent background, by setting `MessageDisplayInCenter` to true.
- If you also set `MessageApplyHoverState` to true, when the mouse hovers over the subtitle area (simply judged as a rectangle), its opacity will increase and it will not disappear during this period.
- You can also let task subtitles (created by trigger 11) to display directly in the middle area of the screen instead of the upper left corner, with a semi transparent background, by setting `MessageDisplayInCenter` to true. In this case, all messages within this game can be saved, even after being s/l.
- If you also set `MessageApplyHoverState` to true, when the mouse hovers over the subtitle area (simply judged as a rectangle), its opacity will increase and it will not disappear during this period. If the area is expanded, disabling this option will not prevent mouse clicking behavior from being restricted to this area.
- `MessageDisplayInCenter.LabelsCount` controls the maximum number of subtitle labels that can automatically pop up at a same time in the middle area of the screen. At least 1.
- `MessageDisplayInCenter.RecordsCount` controls the maximum number of historical messages displayed when this middle area is expanded (not the maximum number that can be stored). At least 4.
- The label can be toggled by ["Toggle Message Label" hotkey](#toggle-message-label) in "Interface" category.

In `RA2MD.INI`:
```ini
[Phobos]
MessageApplyHoverState=false ; boolean
MessageDisplayInCenter=false ; boolean
MessageApplyHoverState=false ; boolean
MessageDisplayInCenter=false ; boolean
MessageDisplayInCenter.LabelsCount=4 ; integer
MessageDisplayInCenter.RecordsCount=12 ; integer
```

### Type select for buildings
Expand Down Expand Up @@ -467,6 +473,11 @@ DisplayIncome.Offset=0,0 ; X,Y, pixels relative to default
- These vanilla CSF entries will be used: `TXT_SAVING_GAME`, `TXT_GAME_WAS_SAVED` and `TXT_ERROR_SAVING_GAME`.
- The save should be looks like `Allied Mission 25: Esther's Money - QuickSaved`.

### `[ ]` Toggle Message Label

- Switches on/off [Task subtitles' label in the middle of the screen](#task-subtitles-display-in-the-middle-of-the-screen).
- For localization add `TXT_TOGGLE_MESSAGE` and `TXT_TOGGLE_MESSAGE_DESC` into your `.csf` file.

## Loading screen

- PCX files can now be used as loadscreen images.
Expand Down
Binary file added docs/_static/images/messagedisplayincenter.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/_static/images/messagedisplayincenter.png
Binary file not shown.
43 changes: 42 additions & 1 deletion src/Commands/Commands.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <CCINIClass.h>
#include "Commands.h"

#include "ObjectInfo.h"
Expand All @@ -12,7 +11,13 @@
#include "SaveVariablesToFile.h"
#include "ToggleSWSidebar.h"
#include "FireTacticalSW.h"
#include "ToggleMessageList.h"

#include <CCINIClass.h>

#include <Utilities/Macro.h>
#include <Ext/Sidebar/SWSidebar/SWSidebarClass.h>
#include <Misc/MessageColumn.h>

DEFINE_HOOK(0x533066, CommandClassCallback_Register, 0x6)
{
Expand All @@ -22,6 +27,7 @@ DEFINE_HOOK(0x533066, CommandClassCallback_Register, 0x6)
MakeCommand<QuickSaveCommandClass>();
MakeCommand<ToggleDigitalDisplayCommandClass>();
MakeCommand<ToggleDesignatorRangeCommandClass>();
MakeCommand<ToggleMessageListCommandClass>();
MakeCommand<ToggleSWSidebar>();

if (Phobos::Config::SuperWeaponSidebarCommands)
Expand Down Expand Up @@ -54,3 +60,38 @@ DEFINE_HOOK(0x533066, CommandClassCallback_Register, 0x6)

return 0;
}

static void MouseWheelDownCommand()
{
if (MessageColumnClass::Instance.IsHovering())
MessageColumnClass::Instance.ScrollDown();
}

static void MouseWheelUpCommand()
{
if (MessageColumnClass::Instance.IsHovering())
MessageColumnClass::Instance.ScrollUp();
}

DEFINE_HOOK(0x777998, Game_WndProc_ScrollMouseWheel, 0x6)
{
GET(const WPARAM, WParam, ECX);

if (WParam & 0x80000000u)
MouseWheelDownCommand();
else
MouseWheelUpCommand();

return 0;
}

static inline bool CheckSkipScrollSidebar()
{
return MessageColumnClass::Instance.IsHovering();
}

DEFINE_HOOK(0x533F50, Game_ScrollSidebar_Skip, 0x5)
{
enum { SkipScrollSidebar = 0x533FC3 };
return CheckSkipScrollSidebar() ? SkipScrollSidebar : 0;
}
29 changes: 29 additions & 0 deletions src/Commands/ToggleMessageList.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "ToggleMessageList.h"

#include <Utilities/GeneralUtils.h>
#include <Misc/MessageColumn.h>

const char* ToggleMessageListCommandClass::GetName() const
{
return "Toggle Message Label";
}

const wchar_t* ToggleMessageListCommandClass::GetUIName() const
{
return GeneralUtils::LoadStringUnlessMissing("TXT_TOGGLE_MESSAGE", L"Toggle Message Label");
}

const wchar_t* ToggleMessageListCommandClass::GetUICategory() const
{
return CATEGORY_INTERFACE;
}

const wchar_t* ToggleMessageListCommandClass::GetUIDescription() const
{
return GeneralUtils::LoadStringUnlessMissing("TXT_TOGGLE_MESSAGE_DESC", L"Toggle message label in the middle of the screen.");
}

void ToggleMessageListCommandClass::Execute(WWKey eInput) const
{
MessageColumnClass::Instance.Toggle();
}
14 changes: 14 additions & 0 deletions src/Commands/ToggleMessageList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include "Commands.h"

// Display damage strings
class ToggleMessageListCommandClass : public CommandClass
{
public:
virtual const char* GetName() const override;
virtual const wchar_t* GetUIName() const override;
virtual const wchar_t* GetUICategory() const override;
virtual const wchar_t* GetUIDescription() const override;
virtual void Execute(WWKey eInput) const override;
};
2 changes: 1 addition & 1 deletion src/Ext/Scenario/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void ScenarioExt::ExtData::Serialize(T& Stm)
.Process(this->TransportReloaders)
.Process(this->SWSidebar_Enable)
.Process(this->SWSidebar_Indices)
// .Process(this->NewMessageList); // Should not S/L
.Process(this->RecordMessages)
;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Ext/Scenario/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ScenarioExt
bool SWSidebar_Enable;
std::vector<int> SWSidebar_Indices;

std::unique_ptr<MessageListClass> NewMessageList;
std::vector<std::wstring> RecordMessages;

ExtData(ScenarioClass* OwnerObject) : Extension<ScenarioClass>(OwnerObject)
, ShowBriefing { false }
Expand All @@ -51,7 +51,7 @@ class ScenarioExt
, TransportReloaders {}
, SWSidebar_Enable { true }
, SWSidebar_Indices {}
, NewMessageList {}
, RecordMessages {}
{ }

void SetVariableToByID(bool bIsGlobal, int nIndex, char bState);
Expand Down
10 changes: 10 additions & 0 deletions src/Ext/Side/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ void SideExt::ExtData::Initialize()

this->ArrayIndex = SideClass::FindIndex(pID);
this->Sidebar_GDIPositions = this->ArrayIndex == 0; // true = Allied

// Init MessageTextColor like Ares
if (!_strcmpi(pID, "Nod")) //Soviets
this->MessageTextColor = 11;
else if (!_strcmpi(pID, "ThirdSide")) //Yuri
this->MessageTextColor = 25;
else //Allies or any other country
this->MessageTextColor = 21;
};

void SideExt::ExtData::LoadFromINIFile(CCINIClass* pINI)
Expand Down Expand Up @@ -40,6 +48,7 @@ void SideExt::ExtData::LoadFromINIFile(CCINIClass* pINI)
this->ToolTip_Background_Opacity.Read(exINI, pSection, "ToolTip.Background.Opacity");
this->ToolTip_Background_BlurSize.Read(exINI, pSection, "ToolTip.Background.BlurSize");
this->BriefingTheme = pINI->ReadTheme(pSection, "BriefingTheme", this->BriefingTheme);
this->MessageTextColor.Read(exINI, pSection, "MessageTextColor");
this->SuperWeaponSidebar_OnPCX.Read(pINI, pSection, "SuperWeaponSidebar.OnPCX");
this->SuperWeaponSidebar_OffPCX.Read(pINI, pSection, "SuperWeaponSidebar.OffPCX");
this->SuperWeaponSidebar_TopPCX.Read(pINI, pSection, "SuperWeaponSidebar.TopPCX");
Expand Down Expand Up @@ -74,6 +83,7 @@ void SideExt::ExtData::Serialize(T& Stm)
.Process(this->IngameScore_WinTheme)
.Process(this->IngameScore_LoseTheme)
.Process(this->BriefingTheme)
.Process(this->MessageTextColor)
.Process(this->SuperWeaponSidebar_OnPCX)
.Process(this->SuperWeaponSidebar_OffPCX)
.Process(this->SuperWeaponSidebar_TopPCX)
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/Side/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class SideExt
Nullable<int> ToolTip_Background_Opacity;
Nullable<float> ToolTip_Background_BlurSize;
Valueable<int> BriefingTheme;
ValueableIdx<ColorScheme> MessageTextColor;
PhobosPCXFile SuperWeaponSidebar_OnPCX;
PhobosPCXFile SuperWeaponSidebar_OffPCX;
PhobosPCXFile SuperWeaponSidebar_TopPCX;
Expand Down Expand Up @@ -63,6 +64,7 @@ class SideExt
, ToolTip_Background_Opacity { }
, ToolTip_Background_BlurSize { }
, BriefingTheme { -1 }
, MessageTextColor { -1 }
, SuperWeaponSidebar_OnPCX {}
, SuperWeaponSidebar_OffPCX {}
, SuperWeaponSidebar_TopPCX {}
Expand Down
22 changes: 12 additions & 10 deletions src/Ext/Sidebar/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include <HouseClass.h>
#include <FactoryClass.h>
#include <FileSystem.h>

#include <Ext/Side/Body.h>
#include <Misc/MessageColumn.h>

DEFINE_HOOK(0x6A593E, SidebarClass_InitForHouse_AdditionalFiles, 0x5)
{
Expand Down Expand Up @@ -99,29 +101,29 @@ DEFINE_HOOK(0x72FCB5, InitSideRectangles_CenterBackground, 0x5)
return 0;
}

#pragma region SWSidebarButtonsRelated
#pragma region NewButtonsRelated

DEFINE_HOOK(0x692419, DisplayClass_ProcessClickCoords_SWSidebar, 0x7)
DEFINE_HOOK(0x692419, DisplayClass_ProcessClickCoords_SkipOnNewButtons, 0x7)
{
enum { DoNothing = 0x6925FC };

if (SWSidebarClass::IsEnabled() && SWSidebarClass::Instance.CurrentColumn)
return DoNothing;

const auto toggleButton = SWSidebarClass::Instance.ToggleButton;

return toggleButton && toggleButton->IsHovering ? DoNothing : 0;
return (SWSidebarClass::IsEnabled() && SWSidebarClass::Instance.CurrentColumn
|| SWSidebarClass::Instance.ToggleButton && SWSidebarClass::Instance.ToggleButton->IsHovering
|| MessageColumnClass::Instance.IsBlocked())
? DoNothing : 0;
}

DEFINE_HOOK(0x6A5082, SidebarClass_InitClear_InitializeSWSidebar, 0x5)
DEFINE_HOOK(0x6A5082, SidebarClass_InitClear_InitializeNewButtons, 0x5)
{
SWSidebarClass::Instance.InitClear();
MessageColumnClass::Instance.InitClear();
return 0;
}

DEFINE_HOOK(0x6A5839, SidebarClass_InitIO_InitializeSWSidebar, 0x5)
DEFINE_HOOK(0x6A5839, SidebarClass_InitIO_InitializeNewButtons, 0x5)
{
SWSidebarClass::Instance.InitIO();
MessageColumnClass::Instance.InitIO();
return 0;
}

Expand Down
Loading
Loading