Skip to content

Commit

Permalink
Improve ingame config menu behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamepiaynmo committed Feb 10, 2021
1 parent 43d0b54 commit 1ca4e40
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 76 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
DebugRelease/
x64/
x86/
[Aa][Rr][Mm]/
Expand Down
6 changes: 6 additions & 0 deletions BML.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
DebugRelease|x64 = DebugRelease|x64
DebugRelease|x86 = DebugRelease|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
Expand All @@ -17,6 +19,10 @@ Global
{AA1E451D-C0D7-415F-8186-4CE370C75314}.Debug|x64.Build.0 = Debug|x64
{AA1E451D-C0D7-415F-8186-4CE370C75314}.Debug|x86.ActiveCfg = Debug|Win32
{AA1E451D-C0D7-415F-8186-4CE370C75314}.Debug|x86.Build.0 = Debug|Win32
{AA1E451D-C0D7-415F-8186-4CE370C75314}.DebugRelease|x64.ActiveCfg = DebugRelease|x64
{AA1E451D-C0D7-415F-8186-4CE370C75314}.DebugRelease|x64.Build.0 = DebugRelease|x64
{AA1E451D-C0D7-415F-8186-4CE370C75314}.DebugRelease|x86.ActiveCfg = DebugRelease|Win32
{AA1E451D-C0D7-415F-8186-4CE370C75314}.DebugRelease|x86.Build.0 = DebugRelease|Win32
{AA1E451D-C0D7-415F-8186-4CE370C75314}.Release|x64.ActiveCfg = Release|x64
{AA1E451D-C0D7-415F-8186-4CE370C75314}.Release|x64.Build.0 = Release|x64
{AA1E451D-C0D7-415F-8186-4CE370C75314}.Release|x86.ActiveCfg = Release|Win32
Expand Down
77 changes: 77 additions & 0 deletions BML.vcxproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="DebugRelease|Win32">
<Configuration>DebugRelease</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="DebugRelease|x64">
<Configuration>DebugRelease</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
Expand Down Expand Up @@ -32,6 +40,12 @@
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
Expand All @@ -45,6 +59,12 @@
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
Expand All @@ -60,12 +80,18 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
Expand All @@ -74,9 +100,16 @@
<LinkIncremental>false</LinkIncremental>
<OutDir>D:\Program Files (x86)\Ballance\BuildingBlocks\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>D:\Program Files (x86)\Ballance\BuildingBlocks\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>D:\Program Files (x86)\Ballance\BuildingBlocks\</OutDir>
Expand All @@ -85,6 +118,35 @@
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;BML_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<StructMemberAlignment>Default</StructMemberAlignment>
<BufferSecurityCheck>false</BufferSecurityCheck>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<SupportJustMyCode>false</SupportJustMyCode>
<LanguageStandard>stdcpplatest</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
Expand Down Expand Up @@ -126,6 +188,21 @@
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;BML_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
Expand Down
175 changes: 100 additions & 75 deletions BMLMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ void GuiList::Exit() {

void GuiList::SetVisible(bool visible) {
Gui::SetVisible(visible);
if (visible) SetPage(0);
if (visible) SetPage(m_curpage);
}

GuiModOption::GuiModOption() {
Expand Down Expand Up @@ -1450,79 +1450,84 @@ GuiModCategory::GuiModCategory(GuiModMenu* parent, Config* config, std::string c
for (Property* prop : m_data) {
std::string name = prop->m_key;
switch (prop->GetType()) {
case IProperty::STRING: {
BGui::Button* bg = AddSettingButton(name.c_str(), name.c_str(), cnt);
bg->SetAlignment(ALIGN_TOP);
bg->SetFont(ExecuteBB::GAMEFONT_03);
bg->SetZOrder(15);
bg->SetOffset(offset);
elements.push_back(bg);
BGui::Input* input = AddTextInput(name.c_str(), ExecuteBB::GAMEFONT_03, 0.43f, cnt + 0.05f, 0.18f, 0.025f);
input->SetText(prop->GetString());
input->SetCallback([this, prop, input](CKDWORD) { prop->SetString(input->GetText()); });
elements.push_back(input);
BGui::Panel* panel = AddPanel(name.c_str(), VxColor(0, 0, 0, 110), 0.43f, cnt + 0.05f, 0.18f, 0.025f);
elements.push_back(panel);
cnt += 0.12f;
break;
}
case IProperty::INTEGER: {
BGui::Button* bg = AddSettingButton(name.c_str(), name.c_str(), cnt);
bg->SetAlignment(ALIGN_TOP);
bg->SetFont(ExecuteBB::GAMEFONT_03);
bg->SetZOrder(15);
bg->SetOffset(offset);
elements.push_back(bg);
BGui::Input* input = AddTextInput(name.c_str(), ExecuteBB::GAMEFONT_03, 0.43f, cnt + 0.05f, 0.18f, 0.025f);
input->SetText(std::to_string(prop->GetInteger()).c_str());
input->SetCallback([this, prop, input](CKDWORD) { prop->SetInteger(atoi(input->GetText())); });
elements.push_back(input);
BGui::Panel* panel = AddPanel(name.c_str(), VxColor(0, 0, 0, 110), 0.43f, cnt + 0.05f, 0.18f, 0.025f);
elements.push_back(panel);
cnt += 0.12f;
break;
}
case IProperty::FLOAT: {
BGui::Button* bg = AddSettingButton(name.c_str(), name.c_str(), cnt);
bg->SetAlignment(ALIGN_TOP);
bg->SetFont(ExecuteBB::GAMEFONT_03);
bg->SetZOrder(15);
bg->SetOffset(offset);
elements.push_back(bg);
BGui::Input* input = AddTextInput(name.c_str(), ExecuteBB::GAMEFONT_03, 0.43f, cnt + 0.05f, 0.18f, 0.025f);
input->SetText(std::to_string(prop->GetFloat()).c_str());
input->SetCallback([this, prop, input](CKDWORD) { prop->SetFloat((float) atof(input->GetText())); });
elements.push_back(input);
BGui::Panel* panel = AddPanel(name.c_str(), VxColor(0, 0, 0, 110), 0.43f, cnt + 0.05f, 0.18f, 0.025f);
elements.push_back(panel);
cnt += 0.12f;
break;
}
case IProperty::KEY: {
std::pair<BGui::Button*, BGui::KeyInput*> key = AddKeyButton(name.c_str(), name.c_str(), cnt);
key.second->SetKey(prop->GetKey());
key.second->SetCallback([this, prop](CKDWORD key) { prop->SetKey(CKKEYBOARD(key)); });
elements.push_back(key.first);
elements.push_back(key.second);
cnt += 0.06f;
break;
}
case IProperty::BOOLEAN: {
BGui::Button* bg = AddSettingButton(name.c_str(), name.c_str(), cnt);
bg->SetAlignment(ALIGN_TOP);
bg->SetFont(ExecuteBB::GAMEFONT_03);
bg->SetZOrder(15);
bg->SetOffset(offset);
elements.push_back(bg);
std::pair<BGui::Button*, BGui::Button*> yesno = AddYesNoButton(name.c_str(), cnt + 0.043f, 0.4350f, 0.5200f,
[this, prop](bool value) { prop->SetBoolean(value); });
yesno.first->SetActive(prop->GetBoolean());
yesno.second->SetActive(!prop->GetBoolean());
elements.push_back(yesno.first);
elements.push_back(yesno.second);
cnt += 0.12f;
break;
}
case IProperty::STRING: {
BGui::Button* bg = AddSettingButton(name.c_str(), name.c_str(), cnt);
bg->SetAlignment(ALIGN_TOP);
bg->SetFont(ExecuteBB::GAMEFONT_03);
bg->SetZOrder(15);
bg->SetOffset(offset);
elements.push_back(bg);
BGui::Input* input = AddTextInput(name.c_str(), ExecuteBB::GAMEFONT_03, 0.43f, cnt + 0.05f, 0.18f, 0.025f);
input->SetText(prop->GetString());
input->SetCallback([this, prop, input](CKDWORD) { prop->SetString(input->GetText()); });
elements.push_back(input);
BGui::Panel* panel = AddPanel(name.c_str(), VxColor(0, 0, 0, 110), 0.43f, cnt + 0.05f, 0.18f, 0.025f);
elements.push_back(panel);
m_inputs.push_back({ input, nullptr });
cnt += 0.12f;
break;
}
case IProperty::INTEGER: {
BGui::Button* bg = AddSettingButton(name.c_str(), name.c_str(), cnt);
bg->SetAlignment(ALIGN_TOP);
bg->SetFont(ExecuteBB::GAMEFONT_03);
bg->SetZOrder(15);
bg->SetOffset(offset);
elements.push_back(bg);
BGui::Input* input = AddTextInput(name.c_str(), ExecuteBB::GAMEFONT_03, 0.43f, cnt + 0.05f, 0.18f, 0.025f);
input->SetText(std::to_string(prop->GetInteger()).c_str());
input->SetCallback([this, prop, input](CKDWORD) { prop->SetInteger(atoi(input->GetText())); });
elements.push_back(input);
BGui::Panel* panel = AddPanel(name.c_str(), VxColor(0, 0, 0, 110), 0.43f, cnt + 0.05f, 0.18f, 0.025f);
elements.push_back(panel);
m_inputs.push_back({ input, nullptr });
cnt += 0.12f;
break;
}
case IProperty::FLOAT: {
BGui::Button* bg = AddSettingButton(name.c_str(), name.c_str(), cnt);
bg->SetAlignment(ALIGN_TOP);
bg->SetFont(ExecuteBB::GAMEFONT_03);
bg->SetZOrder(15);
bg->SetOffset(offset);
elements.push_back(bg);
BGui::Input* input = AddTextInput(name.c_str(), ExecuteBB::GAMEFONT_03, 0.43f, cnt + 0.05f, 0.18f, 0.025f);
input->SetText(std::to_string(prop->GetFloat()).c_str());
input->SetCallback([this, prop, input](CKDWORD) { prop->SetFloat((float) atof(input->GetText())); });
elements.push_back(input);
BGui::Panel* panel = AddPanel(name.c_str(), VxColor(0, 0, 0, 110), 0.43f, cnt + 0.05f, 0.18f, 0.025f);
elements.push_back(panel);
m_inputs.push_back({ input, nullptr });
cnt += 0.12f;
break;
}
case IProperty::KEY: {
std::pair<BGui::Button*, BGui::KeyInput*> key = AddKeyButton(name.c_str(), name.c_str(), cnt);
key.second->SetKey(prop->GetKey());
key.second->SetCallback([this, prop](CKDWORD key) { prop->SetKey(CKKEYBOARD(key)); });
elements.push_back(key.first);
elements.push_back(key.second);
m_inputs.push_back({ key.second, nullptr });
cnt += 0.06f;
break;
}
case IProperty::BOOLEAN: {
BGui::Button* bg = AddSettingButton(name.c_str(), name.c_str(), cnt);
bg->SetAlignment(ALIGN_TOP);
bg->SetFont(ExecuteBB::GAMEFONT_03);
bg->SetZOrder(15);
bg->SetOffset(offset);
elements.push_back(bg);
std::pair<BGui::Button*, BGui::Button*> yesno = AddYesNoButton(name.c_str(), cnt + 0.043f, 0.4350f, 0.5200f,
[this, prop](bool value) { prop->SetBoolean(value); });
yesno.first->SetActive(prop->GetBoolean());
yesno.second->SetActive(!prop->GetBoolean());
elements.push_back(yesno.first);
elements.push_back(yesno.second);
m_inputs.push_back(yesno);
cnt += 0.12f;
break;
}
}

if (cnt > 0.7f) {
Expand All @@ -1544,7 +1549,27 @@ GuiModCategory::GuiModCategory(GuiModMenu* parent, Config* config, std::string c

void GuiModCategory::SetVisible(bool visible) {
Gui::SetVisible(visible);
if (visible) SetPage(0);
if (visible) {
std::vector<Property*> &props = m_config->GetCategory(m_category.c_str()).props;
for (int i = 0; i < props.size(); i++) {
Property* prop = props[i];
m_data[i]->CopyValue(prop);
std::pair<BGui::Element*, BGui::Element*> input = m_inputs[i];
switch (prop->GetType()) {
case IProperty::STRING: reinterpret_cast<BGui::Input*>(input.first)->SetText(prop->GetString()); break;
case IProperty::INTEGER: reinterpret_cast<BGui::Input*>(input.first)->SetText(std::to_string(prop->GetInteger()).c_str()); break;
case IProperty::FLOAT: reinterpret_cast<BGui::Input*>(input.first)->SetText(std::to_string(prop->GetFloat()).c_str()); break;
case IProperty::KEY: reinterpret_cast<BGui::KeyInput*>(input.first)->SetKey(prop->GetKey()); break;
case IProperty::BOOLEAN: {
reinterpret_cast<BGui::Button*>(input.first)->SetActive(prop->GetBoolean());
reinterpret_cast<BGui::Button*>(input.second)->SetActive(!prop->GetBoolean());
break;
}
}
}

SetPage(m_curpage);
}
}

void GuiModCategory::SetPage(int page) {
Expand Down
1 change: 1 addition & 0 deletions BMLMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class GuiModCategory : public BGui::Gui {
private:
std::vector<Property*> m_data;
std::vector<std::vector<BGui::Element*>> m_elements;
std::vector<std::pair<BGui::Element*, BGui::Element*>> m_inputs;
int m_curpage, m_maxpage, m_size;
BGui::Button* m_left, * m_right;

Expand Down
2 changes: 1 addition & 1 deletion BuildVer.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define BML_MAJOR_VER 0
#define BML_MINOR_VER 3
#define BML_BUILD_VER 30
#define BML_BUILD_VER 31

0 comments on commit 1ca4e40

Please sign in to comment.