Hi so im using a paste in cs but the hack wont save settings it doesnt show up
Code:
void CGUI::SaveWindowState(CWindow* window, std::string Filename)
{
// Create a whole new document and we'll just save over top of the old one
tinyxml2::XMLDocument Doc;
// Root Element is called "ayy"
tinyxml2::XMLElement *Root = Doc.NewElement("skeet");
Doc.LinkEndChild(Root);
// If the window has some tabs..
if (Root && window->Tabs.size() > 0)
{
for (auto Tab : window->Tabs)
{
// Add a new section for this tab
tinyxml2::XMLElement *TabElement = Doc.NewElement(Tab->Title.c_str());
Root->LinkEndChild(TabElement);
// Now we itterate the controls this tab contains
if (TabElement && Tab->Controls.size() > 0)
{
for (auto Control : Tab->Controls)
{
// If the control is ok to be saved
if (Control && Control->Flag(UIFlags::UI_SaveFile) && Control->FileIdentifier.length() > 1 && Control->FileControlType)
{
// Create an element for the control
tinyxml2::XMLElement *ControlElement = Doc.NewElement(Control->FileIdentifier.c_str());
TabElement->LinkEndChild(ControlElement);
if (!ControlElement)
{
return;
}
CCheckBox* cbx = nullptr;
CComboBox* cbo = nullptr;
CKeyBind* key = nullptr;
CSlider* sld = nullptr;
CItemSelector* itms = nullptr;
CMultiBox* mtbx = nullptr;
CListBox* lsbox = nullptr;
CColorSelector* clse = nullptr;
// Figure out what kind of control and data this is
switch (Control->FileControlType)
{
case UIControlTypes::UIC_CheckBox:
cbx = (CCheckBox*)Control;
ControlElement->SetText(cbx->GetState());
break;
case UIControlTypes::UIC_ComboBox:
cbo = (CComboBox*)Control;
ControlElement->SetText(cbo->GetIndex());
break;
case UIControlTypes::UIC_KeyBind:
key = (CKeyBind*)Control;
ControlElement->SetText(key->GetKey());
break;
case UIControlTypes::UIC_Slider:
sld = (CSlider*)Control;
ControlElement->SetText(sld->GetValue());
break;
case UIControlTypes::UIC_ItemSelector:
itms = (CItemSelector*)Control;
ControlElement->SetText(itms->GetInt());
break;
case UIControlTypes::UIC_ListBox:
lsbox = (CListBox*)Control;
ControlElement->SetText(lsbox->GetIndex());
break;
case UIControlTypes::UIC_MultiBox:
{
mtbx = (CMultiBox*)Control;
std::string x;
for (int i = 0; i < mtbx->items.size(); i++)
{
std::string status;
status = mtbx->items[i].bselected ? "1" : "0";
x = x + status;
}
ControlElement->SetText(x.c_str());
break;
}
case UIControlTypes::UIC_ColorSelector:
clse = (CColorSelector*)Control;
char buffer[128];
float r, g, b, a;
r = clse->GetValue()[0];
g = clse->GetValue()[1];
b = clse->GetValue()[2];
a = clse->GetValue()[3];
sprintf_s(buffer, "%1.f %1.f %1.f %1.f", r, g, b, a);
ControlElement->SetText(buffer);
break;
}
}
}
}
}
}
//Save the file
if (Doc.SaveFile(Filename.c_str()) != tinyxml2::XML_NO_ERROR)
{
MessageBox(NULL, "Failed To Save Config File!", "SKEET.CC", MB_OK);
}
}
void CGUI::LoadWindowState(CWindow* window, std::string Filename)
{
// Lets load our meme
tinyxml2::XMLDocument Doc;
if (Doc.LoadFile(Filename.c_str()) == tinyxml2::XML_NO_ERROR)
{
tinyxml2::XMLElement *Root = Doc.RootElement();
// The root "ayy" element
if (Root)
{
// If the window has some tabs..
if (Root && window->Tabs.size() > 0)
{
for (auto Tab : window->Tabs)
{
// We find the corresponding element for this tab
tinyxml2::XMLElement *TabElement = Root->FirstChildElement(Tab->Title.c_str());
if (TabElement)
{
// Now we itterate the controls this tab contains
if (TabElement && Tab->Controls.size() > 0)
{
for (auto Control : Tab->Controls)
{
// If the control is ok to be saved
if (Control && Control->Flag(UIFlags::UI_SaveFile) && Control->FileIdentifier.length() > 1 && Control->FileControlType)
{
// Get the controls element
tinyxml2::XMLElement *ControlElement = TabElement->FirstChildElement(Control->FileIdentifier.c_str());
if (ControlElement)
{
CCheckBox* cbx = nullptr;
CComboBox* cbo = nullptr;
CKeyBind* key = nullptr;
CSlider* sld = nullptr;
CItemSelector* itms = nullptr;
CMultiBox* mtbx = nullptr;
CListBox* lsbox = nullptr;
CColorSelector* clse = nullptr;
// Figure out what kind of control and data this is
switch (Control->FileControlType)
{
case UIControlTypes::UIC_CheckBox:
cbx = (CCheckBox*)Control;
cbx->SetState(ControlElement->GetText()[0] == '1' ? true : false);
break;
case UIControlTypes::UIC_ComboBox:
cbo = (CComboBox*)Control;
cbo->SelectIndex(atoi(ControlElement->GetText()));
break;
case UIControlTypes::UIC_KeyBind:
key = (CKeyBind*)Control;
key->SetKey(atoi(ControlElement->GetText()));
break;
case UIControlTypes::UIC_Slider:
sld = (CSlider*)Control;
sld->SetValue(atof(ControlElement->GetText()));
break;
case UIControlTypes::UIC_ItemSelector:
itms = (CItemSelector*)Control;
itms->SetValue(atof(ControlElement->GetText()));
break;
case UIControlTypes::UIC_ListBox:
lsbox = (CListBox*)Control;
lsbox->SelectItem(atoi(ControlElement->GetText()));
break;
case UIControlTypes::UIC_MultiBox:
mtbx = (CMultiBox*)Control;
for (int i = 0; i < mtbx->items.size(); i++)
{
mtbx->items[i].bselected = ControlElement->GetText()[i] == '1' ? true : false;
}
break;
case UIControlTypes::UIC_ColorSelector:
clse = (CColorSelector*)Control;
int r, g, b, a;
std::stringstream ss(ControlElement->GetText());
ss >> r >> g >> b >> a;
clse->SetColor(r, g, b, a);
break;
}
}
}
}
}
}
}
}
}
}
}
i hope someone can help me with this one its a ayyware full fixed base
{edit}
so it isnt saving its the fact that my menu doesnt create the button to see if the config has been made