std::wstring text_address;
std::wstring text_port;
bool creative_mode;
+ bool enable_damage;
{
gui::IGUIElement *e = getElementFromId(258);
else
creative_mode = m_data->creative_mode;
}
+ {
+ gui::IGUIElement *e = getElementFromId(261);
+ if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
+ enable_damage = ((gui::IGUICheckBox*)e)->isChecked();
+ else
+ enable_damage = m_data->enable_damage;
+ }
/*
Remove stuff
/*
Calculate new sizes and positions
*/
+
+ v2s32 size(620, 430);
+
core::rect<s32> rect(
- screensize.X/2 - 580/2,
- screensize.Y/2 - 300/2,
- screensize.X/2 + 580/2,
- screensize.Y/2 + 300/2
+ screensize.X/2 - size.X/2,
+ screensize.Y/2 - size.Y/2,
+ screensize.X/2 + size.X/2,
+ screensize.Y/2 + size.Y/2
);
-
+
DesiredRect = rect;
recalculateAbsolutePosition(false);
- v2s32 size = rect.getSize();
+ //v2s32 size = rect.getSize();
/*
Add stuff
*/
+ /*
+ Client section
+ */
+
+ v2s32 topleft_client(40, 0);
+ v2s32 size_client = size - v2s32(40, 0);
+
+ {
+ core::rect<s32> rect(0, 0, 20, 125);
+ rect += topleft_client + v2s32(-15, 60);
+ const wchar_t *text = L"C\nL\nI\nE\nN\nT";
+ //gui::IGUIStaticText *t =
+ Environment->addStaticText(text, rect, false, true, this, -1);
+ //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
+ }
+
// Nickname
{
core::rect<s32> rect(0, 0, 100, 20);
- rect = rect + v2s32(size.X/2 - 250, size.Y/2 - 100 + 6);
+ rect += topleft_client + v2s32(40, 50+6);
const wchar_t *text = L"Nickname";
Environment->addStaticText(text, rect, false, true, this, -1);
}
{
core::rect<s32> rect(0, 0, 250, 30);
- rect = rect + v2s32(size.X/2 - 130, size.Y/2 - 100);
+ rect += topleft_client + v2s32(160, 50);
gui::IGUIElement *e =
Environment->addEditBox(text_name.c_str(), rect, true, this, 258);
if(text_name == L"")
// Address + port
{
core::rect<s32> rect(0, 0, 100, 20);
- rect = rect + v2s32(size.X/2 - 250, size.Y/2 - 50 + 6);
+ rect += topleft_client + v2s32(40, 100+6);
const wchar_t *text = L"Address + Port";
Environment->addStaticText(text, rect, false, true, this, -1);
}
{
core::rect<s32> rect(0, 0, 250, 30);
- rect = rect + v2s32(size.X/2 - 130, size.Y/2 - 50);
+ rect += topleft_client + v2s32(160, 100);
gui::IGUIElement *e =
Environment->addEditBox(text_address.c_str(), rect, true, this, 256);
if(text_name != L"")
}
{
core::rect<s32> rect(0, 0, 100, 30);
- rect = rect + v2s32(size.X/2 - 130 + 250 + 20, size.Y/2 - 50);
+ //rect += topleft_client + v2s32(160+250+20, 125);
+ rect += topleft_client + v2s32(size_client.X-40-100, 100);
Environment->addEditBox(text_port.c_str(), rect, true, this, 257);
}
{
core::rect<s32> rect(0, 0, 400, 20);
- rect = rect + v2s32(size.X/2 - 130, size.Y/2 - 50 + 35);
+ rect += topleft_client + v2s32(160, 100+35);
const wchar_t *text = L"Leave address blank to start a local server.";
Environment->addStaticText(text, rect, false, true, this, -1);
}
- // Server parameters
+ // Start game button
{
- core::rect<s32> rect(0, 0, 100, 20);
- rect = rect + v2s32(size.X/2 - 250, size.Y/2 + 25 + 6);
- const wchar_t *text = L"Server params";
+ core::rect<s32> rect(0, 0, 180, 30);
+ //rect += topleft_client + v2s32(size_client.X/2-180/2, 225-30/2);
+ rect += topleft_client + v2s32(size_client.X-180-40, 150+25);
+ Environment->addButton(rect, this, 257, L"Start Game / Connect");
+ }
+
+ /*
+ Server section
+ */
+
+ v2s32 topleft_server(40, 250);
+ v2s32 size_server = size - v2s32(40, 0);
+
+ {
+ core::rect<s32> rect(0, 0, 20, 125);
+ rect += topleft_server + v2s32(-15, 40);
+ const wchar_t *text = L"S\nE\nR\nV\nE\nR";
+ //gui::IGUIStaticText *t =
Environment->addStaticText(text, rect, false, true, this, -1);
+ //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
}
+
+ // Server parameters
{
core::rect<s32> rect(0, 0, 250, 30);
- rect = rect + v2s32(size.X/2 - 130, size.Y/2 + 25);
+ rect += topleft_server + v2s32(40, 30);
Environment->addCheckBox(creative_mode, rect, this, 259, L"Creative Mode");
}
- // Start game button
{
- core::rect<s32> rect(0, 0, 180, 30);
- rect = rect + v2s32(size.X/2-180/2, size.Y/2-30/2 + 100);
- Environment->addButton(rect, this, 257, L"Start Game / Connect");
+ core::rect<s32> rect(0, 0, 250, 30);
+ rect += topleft_server + v2s32(40, 60);
+ Environment->addCheckBox(enable_damage, rect, this, 261, L"Enable Damage");
}
// Map delete button
{
core::rect<s32> rect(0, 0, 130, 30);
- rect = rect + v2s32(size.X/2-130/2+200, size.Y/2-30/2 + 100);
+ //rect += topleft_server + v2s32(size_server.X-40-130, 100+25);
+ rect += topleft_server + v2s32(40, 100+25);
Environment->addButton(rect, this, 260, L"Delete map");
}
}
return;
video::IVideoDriver* driver = Environment->getVideoDriver();
+ /*video::SColor bgcolor(140,0,0,0);
+ driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);*/
+
video::SColor bgcolor(140,0,0,0);
- driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);
+
+ {
+ core::rect<s32> rect(0, 0, 620, 230);
+ rect += AbsoluteRect.UpperLeftCorner;
+ driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect);
+ }
+
+ {
+ core::rect<s32> rect(0, 250, 620, 430);
+ rect += AbsoluteRect.UpperLeftCorner;
+ driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect);
+ }
gui::IGUIElement::draw();
}
if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
m_data->creative_mode = ((gui::IGUICheckBox*)e)->isChecked();
}
+ {
+ gui::IGUIElement *e = getElementFromId(261);
+ if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
+ m_data->enable_damage = ((gui::IGUICheckBox*)e)->isChecked();
+ }
m_accepted = true;
}
\r
TODO: Better control of draw_control.wanted_max_blocks\r
\r
+TODO: Get player texture (and some others) from the specified texture\r
+ directory\r
+\r
Configuration:\r
--------------\r
\r
}\r
}\r
\r
+void drawMenuBackground(video::IVideoDriver* driver)\r
+{\r
+ core::dimension2d<u32> screensize = driver->getScreenSize();\r
+ \r
+ video::ITexture *bgtexture =\r
+ driver->getTexture(porting::getDataPath("mud.png").c_str());\r
+ if(bgtexture)\r
+ {\r
+ s32 texturesize = 128;\r
+ s32 tiled_y = screensize.Height / texturesize + 1;\r
+ s32 tiled_x = screensize.Width / texturesize + 1;\r
+ \r
+ for(s32 y=0; y<tiled_y; y++)\r
+ for(s32 x=0; x<tiled_x; x++)\r
+ {\r
+ core::rect<s32> rect(0,0,texturesize,texturesize);\r
+ rect += v2s32(x*texturesize, y*texturesize);\r
+ driver->draw2DImage(bgtexture, rect,\r
+ core::rect<s32>(core::position2d<s32>(0,0),\r
+ core::dimension2di(bgtexture->getSize())),\r
+ NULL, NULL, true);\r
+ }\r
+ }\r
+ \r
+ video::ITexture *logotexture =\r
+ driver->getTexture(porting::getDataPath("menulogo.png").c_str());\r
+ if(logotexture)\r
+ {\r
+ v2s32 logosize(logotexture->getOriginalSize().Width,\r
+ logotexture->getOriginalSize().Height);\r
+ logosize *= 4;\r
+\r
+ video::SColor bgcolor(255,50,50,50);\r
+ core::rect<s32> bgrect(0, screensize.Height-logosize.Y-20,\r
+ screensize.Width, screensize.Height);\r
+ driver->draw2DRectangle(bgcolor, bgrect, NULL);\r
+\r
+ core::rect<s32> rect(0,0,logosize.X,logosize.Y);\r
+ rect += v2s32(screensize.Width/2,screensize.Height-10-logosize.Y);\r
+ rect -= v2s32(logosize.X/2, 0);\r
+ driver->draw2DImage(logotexture, rect,\r
+ core::rect<s32>(core::position2d<s32>(0,0),\r
+ core::dimension2di(logotexture->getSize())),\r
+ NULL, NULL, true);\r
+ }\r
+}\r
+\r
int main(int argc, char *argv[])\r
{\r
/*\r
menudata.name = narrow_to_wide(playername);\r
menudata.port = narrow_to_wide(itos(port));\r
menudata.creative_mode = g_settings.getBool("creative_mode");\r
+ menudata.enable_damage = g_settings.getBool("enable_damage");\r
\r
GUIMainMenu *menu =\r
new GUIMainMenu(guienv, guiroot, -1, \r
\r
//driver->beginScene(true, true, video::SColor(255,0,0,0));\r
driver->beginScene(true, true, video::SColor(255,128,128,128));\r
+\r
+ drawMenuBackground(driver);\r
+\r
guienv->drawAll();\r
+ \r
driver->endScene();\r
}\r
\r
int newport = stoi(wide_to_narrow(menudata.port));\r
if(newport != 0)\r
port = newport;\r
- //port = stoi(wide_to_narrow(menudata.port));\r
g_settings.set("creative_mode", itos(menudata.creative_mode));\r
+ g_settings.set("enable_damage", itos(menudata.enable_damage));\r
\r
// Check for valid parameters, restart menu if invalid.\r
if(playername == "")\r