Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.
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
9 changes: 5 additions & 4 deletions Activities/GameActivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,14 +921,15 @@ int GameActivity::Start()
m_pBuyGUI[player]->Create(&m_PlayerController[player]);

// Load correct loadouts into buy menu if we're starting a non meta-game activity
if (m_pBuyGUI[player]->GetMetaPlayer() == Players::NoPlayer)
{
m_pBuyGUI[player]->SetNativeTechModule(g_PresetMan.GetModuleID(GetTeamTech(GetTeamOfPlayer(player))));
if (m_pBuyGUI[player]->GetMetaPlayer() == Players::NoPlayer) {
int techModuleID = g_PresetMan.GetModuleID(GetTeamTech(GetTeamOfPlayer(player)));

m_pBuyGUI[player]->SetNativeTechModule(techModuleID);
m_pBuyGUI[player]->SetForeignCostMultiplier(1.0);
m_pBuyGUI[player]->LoadAllLoadoutsFromFile();

// Change Editor GUI native tech module so it could load and show correct deployment prices
m_pEditorGUI[player]->SetNativeTechModule(g_PresetMan.GetModuleID(GetTeamTech(GetTeamOfPlayer(player))));
m_pEditorGUI[player]->SetNativeTechModule(techModuleID);
}

////////////////////////////////////
Expand Down
26 changes: 25 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,28 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- New `MovableObject` INI and Lua (R/W) property `SimUpdatesBetweenScriptedUpdates`, that lets `MovableObject`s run their Lua update function less frequently, for performance benefits.

- Added faction themes.
Faction themes apply to the `BuyMenu` when the faction is set as the native module (i.e. playing as the faction) in both Conquest and Scenario battle.

The theme properties are defined in the `DataModule`'s `Index.ini` (before any `IncludeFile` lines) like so:
```
FactionBuyMenuTheme = BuyMenuTheme
SkinFile = pathToSkinFile // GUI element visuals (NOT actual layout).
BackgroundColorIndex = paletteIndex // Color of the parent box that holds all the elements. Palette colors only, no support for images.
BannerFile = pathToBannerImage
LogoFile = pathToLogoImage
```
All properties are optional, any combination works.
The skin and background color are also applied to the `ObjectPicker` (scene object placer) for visual consistency.

- New `Settings.ini` property `DisableFactionBuyMenuThemes = 0/1` which will cause custom faction theme definitions in all modules to be ignored and the default theme to be used instead.

- New `DataModule` INI and Lua (R/O) property `IsMerchant` which determines whether a module is an independent merchant. Defaults to false (0). ([Issue #401](https://github.com/cortex-command-community/Cortex-Command-Community-Project-Source/issues/401))
A module defined as a merchant will stop being playable (in Conquest, etc.) but will have its buyable content available for purchase/placement when playing as any other faction (like how base content is).
Only has a noticeable effect when the "Allow purchases from other factions" (`Settings.ini` `ShowForeignItems`) gameplay setting is disabled.

Note that this property takes priority over the `IsFaction` property. A module that is set as both `IsFaction = 1` and `IsMerchant = 1` will be treated as `IsFaction = 0`.

</details>

<details><summary><b>Changed</b></summary>
Expand Down Expand Up @@ -117,6 +139,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- `Scene` layer data will now be saved as compressed PNG to reduce file sizes of MetaGame saves and is threaded to prevent the game from freezing when layer data is being saved.

- Lua function `BuyMenuGUI:SetHeaderImage` renamed to `SetBannerImage`.

</details>

<details><summary><b>Fixed</b></summary>
Expand Down Expand Up @@ -1332,4 +1356,4 @@ Note: For a log of changes made prior to the commencement of the open source com
[0.1.0-pre1]: https://github.com/cortex-command-community/Cortex-Command-Community-Project-Data/releases/tag/v0.1.0-pre1
[0.1.0-pre2]: https://github.com/cortex-command-community/Cortex-Command-Community-Project-Data/releases/tag/v0.1.0-pre2
[0.1.0-pre3.0]: https://github.com/cortex-command-community/Cortex-Command-Community-Project-Source/releases/tag/v0.1.0-pre3.0
[0.1.0-pre4.0]: https://github.com/cortex-command-community/Cortex-Command-Community-Project-Source/releases/tag/v0.1.0-pre4.0
[0.1.0-pre4.0]: https://github.com/cortex-command-community/Cortex-Command-Community-Project-Source/releases/tag/v0.1.0-pre4.0
12 changes: 8 additions & 4 deletions GUI/GUIListPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ GUIListPanel::GUIListPanel(GUIManager *Manager) : GUIPanel(Manager) {
m_FontColor = 0;
m_FontSelectColor = 0;
m_SelectedColorIndex = 0;
m_UnselectedColorIndex = 0;
m_CapturedHorz = false;
m_CapturedVert = false;
m_ExternalCapture = false;
Expand Down Expand Up @@ -50,6 +51,7 @@ GUIListPanel::GUIListPanel() : GUIPanel() {
m_FontColor = 0;
m_FontSelectColor = 0;
m_SelectedColorIndex = 0;
m_UnselectedColorIndex = 0;
m_CapturedHorz = false;
m_CapturedVert = false;
m_ExternalCapture = false;
Expand Down Expand Up @@ -250,6 +252,9 @@ void GUIListPanel::BuildBitmap(bool UpdateBase, bool UpdateText) {
m_Skin->GetValue("Listbox", "SelectedColorIndex", &m_SelectedColorIndex);
m_SelectedColorIndex = m_Skin->ConvertColor(m_SelectedColorIndex, m_BaseBitmap->GetColorDepth());

m_Skin->GetValue("Listbox", "UnselectedColorIndex", &m_UnselectedColorIndex);
m_UnselectedColorIndex = m_Skin->ConvertColor(m_UnselectedColorIndex, m_BaseBitmap->GetColorDepth());

// Load the font
m_Skin->GetValue("Listbox", "Font", &Filename);
m_Font = m_Skin->GetFont(Filename);
Expand Down Expand Up @@ -346,17 +351,16 @@ void GUIListPanel::BuildDrawBitmap() {
m_Font->DrawAligned(m_DrawBitmap, textX, textY, I->m_Name, GUIFont::Left, GUIFont::Middle, mainTextWidth);
} else {
// Unselected
// TODO: Don't hardcode unselected color index
m_DrawBitmap->DrawLine(4, y + 1, m_Width - (m_VertScroll->_GetVisible() ? m_VertScroll->GetWidth() + 2 : 5), y + 1, 144);
m_DrawBitmap->DrawLine(4, y + itemHeight, m_Width - (m_VertScroll->_GetVisible() ? m_VertScroll->GetWidth() + 2 : 5), y + itemHeight, 144);
m_DrawBitmap->DrawLine(4, y + 1, m_Width - (m_VertScroll->_GetVisible() ? m_VertScroll->GetWidth() + 2 : 5), y + 1, m_UnselectedColorIndex);
m_DrawBitmap->DrawLine(4, y + itemHeight, m_Width - (m_VertScroll->_GetVisible() ? m_VertScroll->GetWidth() + 2 : 5), y + itemHeight, m_UnselectedColorIndex);
m_Font->SetColor(m_FontColor);
m_Font->SetKerning(m_FontKerning);
m_Font->DrawAligned(m_DrawBitmap, x - 6 - (m_VertScroll->_GetVisible() ? m_VertScroll->GetWidth() : 0) + m_Width, textY, I->m_RightText, GUIFont::Right, GUIFont::Middle, m_Width, m_FontShadow);
m_Font->DrawAligned(m_DrawBitmap, textX, textY, I->m_Name, GUIFont::Left, GUIFont::Middle, mainTextWidth, m_FontShadow);
}

// Draw another line to make sure the last item has two
if (it == m_Items.end() - 1) { m_DrawBitmap->DrawLine(4, y + itemHeight + 1, m_Width - 5, y + itemHeight + 1, 144); }
if (it == m_Items.end() - 1) { m_DrawBitmap->DrawLine(4, y + itemHeight + 1, m_Width - 5, y + itemHeight + 1, m_UnselectedColorIndex); }

// Save the item height for later use in selection routines etc
I->m_Height = itemHeight;
Expand Down
1 change: 1 addition & 0 deletions GUI/GUIListPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ class GUIListPanel : public GUIPanel {
std::vector<Item *> m_Items;
std::vector<Item *> m_SelectedList;
unsigned long m_SelectedColorIndex;
unsigned long m_UnselectedColorIndex;

//////////////////////////////////////////////////////////////////////////////////////////
// Method: BuildDrawBitmap
Expand Down
8 changes: 4 additions & 4 deletions GUI/GUISkin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ bool GUISkin::Load(const std::string &directory, const std::string &fileName) {
// Destroy any previous instances
Destroy();

m_Directory = directory;
m_Directory = !directory.empty() ? (directory + "/") : "";

GUIReader skinFile;
if (skinFile.Create((m_Directory + "/" + fileName).c_str()) == -1) {
if (skinFile.Create(m_Directory + fileName) == -1) {
return false;
}

Expand Down Expand Up @@ -210,7 +210,7 @@ GUIBitmap * GUISkin::CreateBitmap(int Width, int Height) {

GUIBitmap * GUISkin::CreateBitmap(const std::string &Filename) {
// Add the filename onto the current directory
std::string File = m_Directory + "/" + Filename;
std::string File = m_Directory + Filename;

// Check if the image is in our cache
std::vector<GUIBitmap *>::iterator it;
Expand Down Expand Up @@ -248,7 +248,7 @@ GUIFont * GUISkin::GetFont(const std::string &Name) {

// Not found, so we create the font
GUIFont *Font = new GUIFont(Name);
if (!Font->Load(m_Screen, m_Directory + "/" + Name)) {
if (!Font->Load(m_Screen, m_Directory + Name)) {
delete Font;
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion Lua/LuaBindingsGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace RTE {
.def("ForceRefresh", &BuyMenuGUI::ForceRefresh)
.def("SetOwnedItemsAmount", &BuyMenuGUI::SetOwnedItemsAmount)
.def("GetOwnedItemsAmount", &BuyMenuGUI::GetOwnedItemsAmount)
.def("SetHeaderImage", &BuyMenuGUI::SetHeaderImage)
.def("SetBannerImage", &BuyMenuGUI::SetBannerImage)
.def("SetLogoImage", &BuyMenuGUI::SetLogoImage)
.def("ClearCartList", &BuyMenuGUI::ClearCartList)
.def("LoadDefaultLoadoutToCart", &BuyMenuGUI::LoadDefaultLoadoutToCart);
Expand Down
1 change: 1 addition & 0 deletions Lua/LuaBindingsSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ namespace RTE {
.property("Description", &DataModule::GetDescription)
.property("Version", &DataModule::GetVersionNumber)
.property("IsFaction", &DataModule::IsFaction)
.property("IsMerchant", &DataModule::IsMerchant)

.def_readwrite("Presets", &DataModule::m_EntityList, luabind::return_stl_iterator);
}
Expand Down
4 changes: 4 additions & 0 deletions Managers/SettingsMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace RTE {
m_RecommendedMOIDCount = 240;
m_SimplifiedCollisionDetection = false;
m_SceneBackgroundAutoScaleMode = 1;
m_DisableFactionBuyMenuThemes = false;

m_SkipIntro = false;
m_ShowToolTips = true;
Expand Down Expand Up @@ -174,6 +175,8 @@ namespace RTE {
reader >> m_SimplifiedCollisionDetection;
} else if (propName == "SceneBackgroundAutoScaleMode") {
SetSceneBackgroundAutoScaleMode(std::stoi(reader.ReadPropValue()));
} else if (propName == "DisableFactionBuyMenuThemes") {
reader >> m_DisableFactionBuyMenuThemes;
} else if (propName == "EnableParticleSettling") {
reader >> g_MovableMan.m_SettlingEnabled;
} else if (propName == "EnableMOSubtraction") {
Expand Down Expand Up @@ -349,6 +352,7 @@ namespace RTE {
writer.NewPropertyWithValue("RecommendedMOIDCount", m_RecommendedMOIDCount);
writer.NewPropertyWithValue("SimplifiedCollisionDetection", m_SimplifiedCollisionDetection);
writer.NewPropertyWithValue("SceneBackgroundAutoScaleMode", m_SceneBackgroundAutoScaleMode);
writer.NewPropertyWithValue("DisableFactionBuyMenuThemes", m_DisableFactionBuyMenuThemes);
writer.NewPropertyWithValue("EnableParticleSettling", g_MovableMan.m_SettlingEnabled);
writer.NewPropertyWithValue("EnableMOSubtraction", g_MovableMan.m_MOSubtractionEnabled);
writer.NewPropertyWithValue("DeltaTime", g_TimerMan.GetDeltaTimeSecs());
Expand Down
13 changes: 13 additions & 0 deletions Managers/SettingsMan.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ namespace RTE {
/// </summary>
/// <param name="newMode">The new Scene background layer auto-scaling mode. 0 for off, 1 for fit screen dimensions and 2 for always upscaled to x2.</param>
void SetSceneBackgroundAutoScaleMode(int newMode) { m_SceneBackgroundAutoScaleMode = std::clamp(newMode, 0, 2); }

/// <summary>
/// Gets whether faction BuyMenu theme support is disabled.
/// </summary>
/// <returns>Whether faction BuyMenu theme support is disabled.</returns>
bool FactionBuyMenuThemesDisabled() const { return m_DisableFactionBuyMenuThemes; }

/// <summary>
/// Sets whether faction BuyMenu theme support is disabled.
/// </summary>
/// <param name="disable">Whether faction BuyMenu theme support is disabled or not.</param>
void SetFactionBuyMenuThemesDisabled(bool disable) { m_DisableFactionBuyMenuThemes = disable; }
#pragma endregion

#pragma region Gameplay Settings
Expand Down Expand Up @@ -470,6 +482,7 @@ namespace RTE {
int m_RecommendedMOIDCount; //!< Recommended max MOID's before removing actors from scenes.
bool m_SimplifiedCollisionDetection; //!< Whether simplified collision detection (reduced MOID layer sampling) is enabled.
int m_SceneBackgroundAutoScaleMode; //!< Scene background layer auto-scaling mode. 0 for off, 1 for fit screen dimensions and 2 for always upscaled to x2.
bool m_DisableFactionBuyMenuThemes; //!< Whether faction BuyMenu theme support is disabled.

bool m_SkipIntro; //!< Whether to play the intro of the game or skip directly to the main menu.
bool m_ShowToolTips; //!< Whether ToolTips are enabled or not.
Expand Down
Loading