launcher: add custom button and spacer plugin config options
This commit is contained in:
@@ -231,6 +231,22 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
ref class CustomFuncHandler
|
||||
{
|
||||
public:
|
||||
void(*_func)();
|
||||
|
||||
CustomFuncHandler(void(*func)())
|
||||
{
|
||||
_func = func;
|
||||
}
|
||||
|
||||
System::Void RunFunc(System::Object^ sender, System::EventArgs^ e)
|
||||
{
|
||||
_func();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class ConfigOptionBase
|
||||
{
|
||||
@@ -276,6 +292,22 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class OptionMetaSpacer : public ConfigOptionBase
|
||||
{
|
||||
public:
|
||||
int _height;
|
||||
|
||||
OptionMetaSpacer(int height)
|
||||
{
|
||||
_height = height;
|
||||
}
|
||||
|
||||
virtual int AddToPanel(Panel^ panel, unsigned int left, unsigned int top, ToolTip^ tooltip)
|
||||
{
|
||||
return _height;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class BooleanOption : public ConfigOptionBase
|
||||
{
|
||||
@@ -945,6 +977,52 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class ButtonOption : public ConfigOptionBase
|
||||
{
|
||||
public:
|
||||
void(*_func)();
|
||||
|
||||
ButtonOption(LPCWSTR friendlyName, LPCWSTR description, void(*func)())
|
||||
{
|
||||
_friendlyName = friendlyName;
|
||||
_description = description;
|
||||
_func = func;
|
||||
}
|
||||
|
||||
virtual int AddToPanel(Panel^ panel, unsigned int left, unsigned int top, ToolTip^ tooltip)
|
||||
{
|
||||
Button^ button = gcnew Button();
|
||||
|
||||
button->Text = gcnew String(_friendlyName);
|
||||
button->Left = left;
|
||||
button->Top = top;
|
||||
button->AutoSize = true;
|
||||
button->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
|
||||
|
||||
Form^ RootForm = panel->FindForm();
|
||||
float ScaleWidth = 1.0f;
|
||||
float ScaleHeight = 1.0f;
|
||||
if (RootForm)
|
||||
{
|
||||
Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions;
|
||||
ScaleWidth = CurrentScaleSize.Width / BaseScaleSize;
|
||||
ScaleHeight = CurrentScaleSize.Height / BaseScaleSize;
|
||||
}
|
||||
button->Scale(ScaleWidth, ScaleHeight);
|
||||
|
||||
tooltip->SetToolTip(button, gcnew String(_description));
|
||||
|
||||
CustomFuncHandler^ funchandler = gcnew CustomFuncHandler(_func);
|
||||
button->Click += gcnew System::EventHandler(funchandler, &CustomFuncHandler::RunFunc);
|
||||
|
||||
panel->Controls->Add(button);
|
||||
|
||||
int ControlHeight = button->Height / ScaleHeight;
|
||||
return ControlHeight + ControlSpacing;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class PluginOption : public ConfigOptionBase
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace PluginConfig
|
||||
PluginConfigDropdownNumberData* ddNumberData = (PluginConfigDropdownNumberData*)(cfg.data);
|
||||
PluginConfigResolutionData* resData = (PluginConfigResolutionData*)(cfg.data);
|
||||
PluginConfigGroupData* groupData = (PluginConfigGroupData*)(cfg.data);
|
||||
PluginConfigButtonData* btnData = (PluginConfigButtonData*)(cfg.data);
|
||||
PluginConfigSpacerData* spacerData = (PluginConfigSpacerData*)(cfg.data);
|
||||
|
||||
switch (cfg.cfgType)
|
||||
{
|
||||
@@ -35,6 +37,10 @@ namespace PluginConfig
|
||||
return new OptionMetaGroupStart(groupData->name, groupData->height);
|
||||
case CONFIG_GROUP_END:
|
||||
return new OptionMetaGroupEnd();
|
||||
case CONFIG_BUTTON:
|
||||
return new ButtonOption(btnData->friendlyName, btnData->description, btnData->func);
|
||||
case CONFIG_SPACER:
|
||||
return new OptionMetaSpacer(spacerData->height);
|
||||
default:
|
||||
return new ConfigOptionBase();
|
||||
}
|
||||
|
||||
@@ -56,7 +56,9 @@ namespace PluginConfig
|
||||
CONFIG_DROPDOWN_NUMBER,
|
||||
CONFIG_RESOLUTION,
|
||||
CONFIG_GROUP_START,
|
||||
CONFIG_GROUP_END
|
||||
CONFIG_GROUP_END,
|
||||
CONFIG_BUTTON,
|
||||
CONFIG_SPACER
|
||||
};
|
||||
|
||||
struct PluginConfigBooleanData {
|
||||
@@ -141,6 +143,16 @@ namespace PluginConfig
|
||||
int height;
|
||||
};
|
||||
|
||||
struct PluginConfigButtonData {
|
||||
LPCWSTR friendlyName;
|
||||
LPCWSTR description;
|
||||
void(*func)();
|
||||
};
|
||||
|
||||
struct PluginConfigSpacerData {
|
||||
int height;
|
||||
};
|
||||
|
||||
struct PluginConfigOption
|
||||
{
|
||||
ConfigType cfgType;
|
||||
|
||||
Reference in New Issue
Block a user