fix utf-8 and numpad in editboxes

master
darkrose 2014-11-17 23:11:50 +10:00
parent daa6793a6b
commit d7e374aed7
17 changed files with 1829 additions and 195 deletions

View File

@ -281,6 +281,10 @@ include_directories(
)
if(USE_FREETYPE)
set(voxelands_SRCS
${voxelands_SRCS}
intlGUIEditBox.cpp
)
include_directories(
${FREETYPE_INCLUDE_DIRS}
${CGUITTFONT_INCLUDE_DIR}

View File

@ -55,7 +55,6 @@ GUICharDefMenu::GUICharDefMenu(
fetchPlayerSkin();
changeCtype("");
m_skintone_types["white"] = wgettext("White Skin");
m_skintone_types["red"] = wgettext("Red Skin");
m_skintone_types["green"] = wgettext("Green Skin");
@ -115,7 +114,6 @@ GUICharDefMenu::GUICharDefMenu(
m_shoes_types["leather"] = wgettext("Leather Shoes");
m_shoes_types["fur"] = wgettext("Fur Shoes");
m_shoes_types["canvas"] = wgettext("Canvas Shoes");
changeCtype("C");
scene::ISceneManager* smgr = device->getSceneManager();
@ -199,7 +197,6 @@ void GUICharDefMenu::regenerateGui(v2u32 screensize)
DesiredRect = rect;
recalculateAbsolutePosition(false);
changeCtype("");
{
core::rect<s32> rect(0, 0, 230, 300);
rect += leftside + v2s32(10, 220);
@ -229,7 +226,6 @@ void GUICharDefMenu::regenerateGui(v2u32 screensize)
gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Create Your Character"), rect, false, true, this, -1);
t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
}
//changeCtype("C");
// gender
{
core::rect<s32> rect(0, 0, 105, 30);
@ -268,14 +264,12 @@ void GUICharDefMenu::regenerateGui(v2u32 screensize)
// skintone
//185
//changeCtype("");
{
core::rect<s32> rect(0, 0, 160, 20);
rect += rightside + v2s32(45, 170);
gui::IGUIStaticText *t = Environment->addStaticText(m_skintone_types[m_parts["skintone"]].c_str(), rect, false, true, this, -1);
t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
}
//changeCtype("C");
{
core::rect<s32> rect(0, 0, 30, 30);
rect += rightside + v2s32(15, 165);
@ -289,14 +283,12 @@ void GUICharDefMenu::regenerateGui(v2u32 screensize)
// face
//220
//changeCtype("");
{
core::rect<s32> rect(0, 0, 160, 20);
rect += rightside + v2s32(45, 205);
gui::IGUIStaticText *t = Environment->addStaticText(m_face_types[m_parts["face"]].c_str(), rect, false, true, this, -1);
t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
}
//changeCtype("C");
{
core::rect<s32> rect(0, 0, 30, 30);
rect += rightside + v2s32(15, 200);
@ -310,14 +302,12 @@ void GUICharDefMenu::regenerateGui(v2u32 screensize)
// hairtone
//255
//changeCtype("");
{
core::rect<s32> rect(0, 0, 160, 20);
rect += rightside + v2s32(45, 240);
gui::IGUIStaticText *t = Environment->addStaticText(m_hairtone_types[m_parts["hairtone"]].c_str(), rect, false, true, this, -1);
t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
}
//changeCtype("C");
{
core::rect<s32> rect(0, 0, 30, 30);
rect += rightside + v2s32(15, 235);
@ -331,14 +321,12 @@ void GUICharDefMenu::regenerateGui(v2u32 screensize)
// hair
//290
//changeCtype("");
{
core::rect<s32> rect(0, 0, 160, 20);
rect += rightside + v2s32(45, 275);
gui::IGUIStaticText *t = Environment->addStaticText(m_hair_types[m_parts["hair"]].c_str(), rect, false, true, this, -1);
t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
}
//changeCtype("C");
{
core::rect<s32> rect(0, 0, 30, 30);
rect += rightside + v2s32(15, 270);
@ -352,14 +340,12 @@ void GUICharDefMenu::regenerateGui(v2u32 screensize)
// eyes
//325
//changeCtype("");
{
core::rect<s32> rect(0, 0, 160, 20);
rect += rightside + v2s32(45, 315);
gui::IGUIStaticText *t = Environment->addStaticText(m_eyes_types[m_parts["eyes"]].c_str(), rect, false, true, this, -1);
t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
}
//changeCtype("C");
{
core::rect<s32> rect(0, 0, 30, 30);
rect += rightside + v2s32(15, 305);
@ -373,14 +359,12 @@ void GUICharDefMenu::regenerateGui(v2u32 screensize)
// t-shirt
//370
//changeCtype("");
{
core::rect<s32> rect(0, 0, 160, 20);
rect += rightside + v2s32(45, 355);
gui::IGUIStaticText *t = Environment->addStaticText(m_shirt_types[m_parts["shirt"]].c_str(), rect, false, true, this, -1);
t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
}
//changeCtype("C");
{
core::rect<s32> rect(0, 0, 30, 30);
rect += rightside + v2s32(15, 350);
@ -394,14 +378,12 @@ void GUICharDefMenu::regenerateGui(v2u32 screensize)
// pants
//405
//changeCtype("");
{
core::rect<s32> rect(0, 0, 160, 20);
rect += rightside + v2s32(45, 390);
gui::IGUIStaticText *t = Environment->addStaticText(m_pants_types[m_parts["pants"]].c_str(), rect, false, true, this, -1);
t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
}
//changeCtype("C");
{
core::rect<s32> rect(0, 0, 30, 30);
rect += rightside + v2s32(15, 385);
@ -415,14 +397,12 @@ void GUICharDefMenu::regenerateGui(v2u32 screensize)
// shoes
//440
//changeCtype("");
{
core::rect<s32> rect(0, 0, 160, 20);
rect += rightside + v2s32(45, 425);
gui::IGUIStaticText *t = Environment->addStaticText(m_shoes_types[m_parts["shoes"]].c_str(), rect, false, true, this, -1);
t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
}
//changeCtype("C");
{
core::rect<s32> rect(0, 0, 30, 30);
rect += rightside + v2s32(15, 420);
@ -445,7 +425,6 @@ void GUICharDefMenu::regenerateGui(v2u32 screensize)
rect += rightside + v2s32(130, 460);
Environment->addButton(rect, this, GUI_ID_CD_QUIT_BUTTON, wgettext("Cancel"));
}
changeCtype("C");
}
void GUICharDefMenu::drawMenu()

View File

@ -352,9 +352,7 @@ void draw_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font,
p,
sdim
);
changeCtype("");
font->draw(selected.c_str(), rect2, video::SColor(255,255,255,255), false, false, NULL);
changeCtype("C");
}
}
@ -731,7 +729,6 @@ void drawLoadingScreen(video::IVideoDriver* driver, const std::wstring msg)
}
if (guienv) {
std::wstring m;
changeCtype("");
if (msg != L"") {
m = msg;
}else{
@ -742,7 +739,6 @@ void drawLoadingScreen(video::IVideoDriver* driver, const std::wstring msg)
gui::IGUIStaticText *guitext = guienv->addStaticText(m.c_str(),rect);
guienv->drawAll();
guitext->remove();
changeCtype("C");
}
driver->endScene();
@ -810,9 +806,7 @@ void the_game(
Draw "Loading" screen
*/
//draw_load_screen(L"Loading...", driver, font);
changeCtype("");
drawLoadingScreen(driver,wgettext("Loading..."));
changeCtype("C");
/*
Create server.
@ -821,9 +815,7 @@ void the_game(
SharedPtr<Server> server;
if(address == ""){
//draw_load_screen(L"Creating server...", driver, font);
changeCtype("");
drawLoadingScreen(driver,wgettext("Creating server..."));
changeCtype("C");
infostream<<"Creating server"<<std::endl;
server = new Server(map_dir, configpath);
server->start(port);
@ -834,16 +826,12 @@ void the_game(
*/
//draw_load_screen(L"Creating client...", driver, font);
changeCtype("");
drawLoadingScreen(driver,wgettext("Creating client..."));
changeCtype("C");
infostream<<"Creating client"<<std::endl;
MapDrawControl draw_control;
Client client(device, playername.c_str(), password, draw_control, sound);
changeCtype("");
drawLoadingScreen(driver,wgettext("Resolving address..."));
changeCtype("C");
Address connect_address(0,0,0,0, port);
try{
if(address == "")
@ -888,7 +876,6 @@ void the_game(
break;
}
changeCtype("");
wchar_t buff[512];
int tot = (10.0 - time_counter + 1.0);
swprintf(
@ -903,7 +890,6 @@ void the_game(
);
//draw_load_screen(ss.str(), driver, font);
drawLoadingScreen(driver,std::wstring(buff));
changeCtype("C");
// Update client and server
client.step(0.1);
@ -2379,9 +2365,7 @@ void the_game(
generator and other stuff quits
*/
{
changeCtype("");
drawLoadingScreen(driver,wgettext("Shutting down..."));
changeCtype("C");
}
}

View File

@ -18,25 +18,13 @@ inline void init_gettext(const char *path) {
// don't do this if MSVC compiler is used, it gives an assertion fail
#ifndef _MSC_VER
setlocale(LC_MESSAGES, "");
setlocale(LC_CTYPE, "");
#endif
bindtextdomain(PROJECT_NAME, path);
textdomain(PROJECT_NAME);
#endif
}
inline void changeCtype(const char *l)
{
char *ret = NULL;
ret = setlocale(LC_CTYPE, l);
#ifndef NDEBUG
if (ret == NULL) {
std::cout<<"locale could not be set"<<std::endl;
}else{
std::cout<<"locale has been set to:"<<ret<<std::endl;
}
#endif
}
inline wchar_t* chartowchar_t(const char *str)
{
size_t l = strlen(str)+1;
@ -47,17 +35,13 @@ inline wchar_t* chartowchar_t(const char *str)
inline wchar_t* wgettext(const char *str)
{
changeCtype("");
wchar_t *r = chartowchar_t(gettext(str));
changeCtype("C");
return r;
}
inline wchar_t* wngettext(const char *str1, const char *str2, int n)
{
changeCtype("");
wchar_t *r = chartowchar_t(ngettext(str1,str2,n));
changeCtype("C");
return r;
}
#define GETTEXT_HEADER

View File

@ -91,22 +91,17 @@ void GUIDeathScreen::regenerateGui(v2u32 screensize)
/*
Add stuff
*/
changeCtype("");
{
core::rect<s32> rect(0, 0, 400, 50);
rect = rect + v2s32(size.X/2-400/2, size.Y/2-50/2-25);
Environment->addStaticText(wgettext("You died."), rect, false,
true, this, 256);
Environment->addStaticText(wgettext("You died."), rect, false, true, this, 256);
}
{
core::rect<s32> rect(0, 0, 140, 30);
rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25);
gui::IGUIElement *e =
Environment->addButton(rect, this, 257,
wgettext("Respawn"));
gui::IGUIElement *e = Environment->addButton(rect, this, 257, wgettext("Respawn"));
Environment->setFocus(e);
}
changeCtype("C");
}
void GUIDeathScreen::drawMenu()

View File

@ -39,8 +39,10 @@
#include "tile.h" // ITextureSource
#include "path.h"
#include "gui_colours.h"
#include "gettext.h"
#if USE_FREETYPE
#include "intlGUIEditBox.h"
#endif
void drawInventoryItem(video::IVideoDriver *driver,
gui::IGUIFont *font,
@ -316,7 +318,12 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
// three cases: field and no label, label and no field, label and field
if (flabel == "") {
spec.send = true;
gui::IGUIEditBox *e = Environment->addEditBox(spec.fdefault.c_str(), rect, false, this, spec.fid);
gui::IGUIEditBox *e;
#if USE_FREETYPE
e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(spec.fdefault.c_str(), true, Environment, this, spec.fid, rect);
#else
e = Environment->addEditBox(spec.fdefault.c_str(), rect, false, this, spec.fid);
#endif
if (multi) {
e->setMultiLine(true);
e->setTextAlignment(gui::EGUIA_UPPERLEFT, gui::EGUIA_UPPERLEFT);
@ -333,7 +340,12 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
Environment->addStaticText(spec.flabel.c_str(), rect, false, true, this, spec.fid);
}else{
spec.send = true;
gui::IGUIEditBox *e = Environment->addEditBox(spec.fdefault.c_str(), rect, false, this, spec.fid);
gui::IGUIEditBox *e;
#if USE_FREETYPE
e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(spec.fdefault.c_str(), true, Environment, this, spec.fid, rect);
#else
e = Environment->addEditBox(spec.fdefault.c_str(), rect, false, this, spec.fid);
#endif
if (multi) {
e->setMultiLine(true);
e->setWordWrap(true);
@ -452,13 +464,11 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
// If there's inventory, put the usage string at the bottom
if (m_inventorylists.size())
{
changeCtype("");
core::rect<s32> rect(0, 0, size.X-padding.X*2, helptext_h);
rect = rect + v2s32(size.X/2 - rect.getWidth()/2,
size.Y-rect.getHeight()-5);
const wchar_t *text = wgettext("Left click: Move all items, Right click: Move single item");
Environment->addStaticText(text, rect, false, true, this, 256);
changeCtype("C");
}
// If there's fields, add a Proceed button
if (m_fields.size() && bp_set != 2)
@ -474,7 +484,6 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
recalculateAbsolutePosition(false);
basepos = getBasePos();
changeCtype("");
{
v2s32 pos = basepos;
pos.Y = ((m_fields.size()+1)*50);
@ -483,7 +492,6 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
rect = core::rect<s32>(size.X/2-70, pos.Y, (size.X/2-70)+140, pos.Y+25);
Environment->addButton(rect, this, 257, wgettext("Write It"));
}
changeCtype("C");
}
// Add tooltip
{

View File

@ -84,7 +84,6 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
recalculateAbsolutePosition(false);
v2s32 topleft(0, 0);
changeCtype("");
{
core::rect < s32 > rect(0, 0, 620, 20);
rect += topleft + v2s32(0, 10);
@ -313,7 +312,6 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON,
wgettext("Cancel"));
}
changeCtype("C");
}
void GUIKeyChangeMenu::drawMenu()
@ -436,7 +434,6 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
if (event.EventType == EET_KEY_INPUT_EVENT && activeKey >= 0
&& event.KeyInput.PressedDown)
{
changeCtype("");
KeyPress kp(event.KeyInput);
if (activeKey == GUI_ID_KEY_FORWARD_BUTTON)
@ -509,7 +506,6 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
this->dump->setText(wgettext(kp.name()));
this->key_dump = kp;
}
changeCtype("C");
activeKey = -1;
return true;
}
@ -528,11 +524,6 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
}
if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED)
{
if(event.GUIEvent.Caller->getID() != GUI_ID_BACK_BUTTON &&
event.GUIEvent.Caller->getID() != GUI_ID_ABORT_BUTTON)
{
changeCtype("");
}
switch (event.GUIEvent.Caller->getID())
{
@ -614,8 +605,6 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
this->range->setText(wgettext("press Key"));
break;
}
//Buttons
changeCtype("C");
}
}

View File

@ -38,6 +38,9 @@
#include <IGUIFont.h>
#include "path.h"
#include "gui_colours.h"
#if USE_FREETYPE
#include "intlGUIEditBox.h"
#endif
#include "gettext.h"
@ -390,7 +393,6 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
DesiredRect = rect;
recalculateAbsolutePosition(false);
changeCtype("");
// Character Creator button
{
core::rect<s32> rect(0, 0, 200, 40);
@ -427,7 +429,6 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
rect += v2s32(35, 440);
Environment->addButton(rect, this, GUI_ID_TAB_QUIT, wgettext("Quit"));
}
changeCtype("C");
v2s32 topleft_content(250, 0);
v2s32 size_content = size - v2s32(300, 0);
@ -457,7 +458,6 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
}
if (m_data->selected_tab == TAB_MULTIPLAYER) {
changeCtype("");
{
core::rect<s32> rect(0, 0, 550, 20);
rect += topleft_content + v2s32(0, 20);
@ -471,47 +471,60 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
rect += topleft_content + v2s32(120, 60);
Environment->addStaticText(wgettext("Name/Password"), rect, false, true, this, -1);
}
changeCtype("C");
{
core::rect<s32> rect(0, 0, 230, 30);
rect += topleft_content + v2s32(135, 90);
gui::IGUIElement *e =
Environment->addEditBox(text_name.c_str(), rect, false, this, GUI_ID_NAME_INPUT);
gui::IGUIEditBox *e;
#if USE_FREETYPE
e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(text_name.c_str(), true, Environment, this, GUI_ID_NAME_INPUT, rect);
#else
e = Environment->addEditBox(text_name.c_str(), rect, false, this, GUI_ID_NAME_INPUT);
#endif
if (text_name == L"")
Environment->setFocus(e);
}
{
core::rect<s32> rect(0, 0, 230, 30);
rect += topleft_content + v2s32(135, 125);
gui::IGUIEditBox *e =
Environment->addEditBox(L"", rect, false, this, 264);
gui::IGUIEditBox *e;
#if USE_FREETYPE
e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(L"", true, Environment, this, GUI_ID_PW_INPUT, rect);
#else
*e = Environment->addEditBox(L"", rect, false, this, GUI_ID_PW_INPUT);
#endif
e->setPasswordBox(true);
if (text_name != L"" && text_address != L"")
Environment->setFocus(e);
}
changeCtype("");
// Address + port
{
core::rect<s32> rect(0, 0, 110, 20);
rect += topleft_content + v2s32(120, 170);
Environment->addStaticText(wgettext("Address/Port"), rect, false, true, this, -1);
}
changeCtype("C");
{
core::rect<s32> rect(0, 0, 230, 30);
rect += topleft_content + v2s32(135, 200);
gui::IGUIElement *e =
Environment->addEditBox(text_address.c_str(), rect, false, this, GUI_ID_ADDRESS_INPUT);
gui::IGUIEditBox *e;
#if USE_FREETYPE
e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(text_address.c_str(), true, Environment, this, GUI_ID_ADDRESS_INPUT, rect);
#else
e = Environment->addEditBox(text_address.c_str(), rect, false, this, GUI_ID_ADDRESS_INPUT);
#endif
if (text_name != L"" && text_address == L"")
Environment->setFocus(e);
}
{
core::rect<s32> rect(0, 0, 120, 30);
rect += topleft_content + v2s32(245, 240);
Environment->addEditBox(text_port.c_str(), rect, false, this, GUI_ID_PORT_INPUT);
gui::IGUIEditBox *e;
#if USE_FREETYPE
e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(text_port.c_str(), true, Environment, this, GUI_ID_PORT_INPUT, rect);
#else
e = Environment->addEditBox(text_port.c_str(), rect, false, this, GUI_ID_PORT_INPUT);
#endif
}
changeCtype("");
// Start game button
{
core::rect<s32> rect(0, 0, 180, 30);
@ -519,7 +532,6 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, wgettext("Connect"));
}
}else if (m_data->selected_tab == TAB_SETTINGS) {
changeCtype("");
{
core::rect<s32> rect(0, 0, 550, 20);
rect += topleft_content + v2s32(0, 20);
@ -584,7 +596,6 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
Environment->addButton(rect, this, GUI_ID_CHANGE_KEYS_BUTTON, wgettext("Change keys"));
}
}else if (m_data->selected_tab == TAB_SINGLEPLAYER) {
changeCtype("");
{
core::rect<s32> rect(0, 0, 550, 20);
rect += topleft_content + v2s32(0, 20);
@ -627,7 +638,6 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, wgettext("Start Game"));
}
}else if (m_data->selected_tab == TAB_SINGLEPLAYER_ADVANCED) {
changeCtype("");
{
core::rect<s32> rect(0, 0, 550, 20);
rect += topleft_content + v2s32(0, 20);
@ -726,7 +736,6 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, wgettext("Start Game"));
}
}else if (m_data->selected_tab == TAB_SINGLEPLAYER_MAP) {
changeCtype("");
{
core::rect<s32> rect(0, 0, 550, 20);
rect += topleft_content + v2s32(0, 20);
@ -822,13 +831,16 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Map Seed"), rect, false, true, this, -1);
t->setTextAlignment(gui::EGUIA_LOWERRIGHT, gui::EGUIA_UPPERLEFT);
}
changeCtype("C");
{
core::rect<s32> rect(0, 0, 190, 30);
rect += topleft_content + v2s32(190, 260);
Environment->addEditBox(fixed_seed.c_str(), rect, false, this, GUI_ID_MAP_SEED_INPUT);
gui::IGUIEditBox *e;
#if USE_FREETYPE
e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(fixed_seed.c_str(), true, Environment, this, GUI_ID_MAP_SEED_INPUT, rect);
#else
e = Environment->addEditBox(fixed_seed.c_str(), rect, false, this, GUI_ID_MAP_SEED_INPUT);
#endif
}
changeCtype("");
}
}else{
{
@ -882,7 +894,6 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
}
}
changeCtype("C");
}
void GUIMainMenu::drawMenu()
@ -936,7 +947,7 @@ void GUIMainMenu::acceptInput()
}
}
{
gui::IGUIElement *e = getElementFromId(264);
gui::IGUIElement *e = getElementFromId(GUI_ID_PW_INPUT);
if(e != NULL)
m_data->password = e->getText();
}
@ -1363,7 +1374,7 @@ bool GUIMainMenu::OnEvent(const SEvent& event)
case GUI_ID_ADDRESS_INPUT:
case GUI_ID_PORT_INPUT:
case GUI_ID_NAME_INPUT:
case 264:
case GUI_ID_PW_INPUT:
acceptInput();
quitMenu();
return true;

View File

@ -36,6 +36,7 @@
enum {
GUI_ID_QUIT_BUTTON = 101,
GUI_ID_NAME_INPUT,
GUI_ID_PW_INPUT,
GUI_ID_ADDRESS_INPUT,
GUI_ID_PORT_INPUT,
GUI_ID_FANCYTREE_CB,

View File

@ -104,7 +104,6 @@ void GUIMessageMenu::regenerateGui(v2u32 screensize)
Environment->addStaticText(m_message_text.c_str(), rect, false,
true, this, 256);
}
changeCtype("");
{
core::rect<s32> rect(0, 0, 140, 30);
rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25);
@ -113,7 +112,6 @@ void GUIMessageMenu::regenerateGui(v2u32 screensize)
wgettext("Continue"));
Environment->setFocus(e);
}
changeCtype("C");
}
void GUIMessageMenu::drawMenu()

View File

@ -33,9 +33,11 @@
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include "gettext.h"
#include "gui_colours.h"
#if USE_FREETYPE
#include "intlGUIEditBox.h"
#endif
const int ID_oldPassword = 256;
const int ID_newPassword1 = 257;
@ -98,57 +100,59 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize)
Add stuff
*/
s32 ypos = 30;
changeCtype("");
{
core::rect<s32> rect(0, 0, 110, 20);
rect += topleft_client + v2s32(35, ypos+6);
Environment->addStaticText(wgettext("Old Password"),
rect, false, true, this, -1);
Environment->addStaticText(wgettext("Old Password"), rect, false, true, this, -1);
}
changeCtype("C");
{
core::rect<s32> rect(0, 0, 230, 30);
rect += topleft_client + v2s32(160, ypos);
gui::IGUIEditBox *e =
Environment->addEditBox(L"", rect, false, this, ID_oldPassword);
gui::IGUIEditBox *e;
#if USE_FREETYPE
e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(L"", true, Environment, this, ID_oldPassword, rect);
#else
e = Environment->addEditBox(L"", rect, false, this, ID_oldPassword);
#endif
Environment->setFocus(e);
e->setPasswordBox(true);
}
ypos += 50;
changeCtype("");
{
core::rect<s32> rect(0, 0, 110, 20);
rect += topleft_client + v2s32(35, ypos+6);
Environment->addStaticText(wgettext("New Password"),
rect, false, true, this, -1);
Environment->addStaticText(wgettext("New Password"), rect, false, true, this, -1);
}
changeCtype("C");
{
core::rect<s32> rect(0, 0, 230, 30);
rect += topleft_client + v2s32(160, ypos);
gui::IGUIEditBox *e =
Environment->addEditBox(L"", rect, false, this, ID_newPassword1);
gui::IGUIEditBox *e;
#if USE_FREETYPE
e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(L"", true, Environment, this, ID_newPassword1, rect);
#else
e = Environment->addEditBox(L"", rect, false, this, ID_newPassword1);
#endif
e->setPasswordBox(true);
}
ypos += 50;
changeCtype("");
{
core::rect<s32> rect(0, 0, 110, 20);
rect += topleft_client + v2s32(35, ypos+6);
Environment->addStaticText(wgettext("Confirm Password"),
rect, false, true, this, -1);
Environment->addStaticText(wgettext("Confirm Password"), rect, false, true, this, -1);
}
changeCtype("C");
{
core::rect<s32> rect(0, 0, 230, 30);
rect += topleft_client + v2s32(160, ypos);
gui::IGUIEditBox *e =
Environment->addEditBox(L"", rect, false, this, ID_newPassword2);
gui::IGUIEditBox *e;
#if USE_FREETYPE
e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(L"", true, Environment, this, ID_newPassword2, rect);
#else
e = Environment->addEditBox(L"", rect, false, this, ID_newPassword2);
#endif
e->setPasswordBox(true);
}
ypos += 50;
changeCtype("");
{
core::rect<s32> rect(0, 0, 140, 30);
rect = rect + v2s32(size.X/2-140/2, ypos);
@ -160,12 +164,9 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize)
core::rect<s32> rect(0, 0, 300, 20);
rect += topleft_client + v2s32(35, ypos);
IGUIElement *e =
Environment->addStaticText(
wgettext("Passwords do not match!"),
rect, false, true, this, ID_message);
Environment->addStaticText(wgettext("Passwords do not match!"), rect, false, true, this, ID_message);
e->setVisible(false);
}
changeCtype("C");
}

View File

@ -85,10 +85,9 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize)
recalculateAbsolutePosition(false);
v2s32 size = rect.getSize();
changeCtype("");
{
core::rect<s32> rect(0, 0, 380, 20);
rect = rect + v2s32(20 , 10);
core::rect<s32> rect(0, 0, 340, 20);
rect = rect + v2s32(0 , 10);
v2u32 max_texture_size;
{
@ -99,8 +98,8 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize)
Environment->addStaticText(wgettext("Voxelands by darkrose and contributors"), rect, false, true, this, 259);
}
{
core::rect<s32> rect(0, 0, 200, 20);
rect = rect + v2s32(85 , 30);
core::rect<s32> rect(0, 0, 340, 20);
rect = rect + v2s32(0 , 30);
v2u32 max_texture_size;
{
@ -111,8 +110,8 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize)
Environment->addStaticText(L"www.voxelands.com", rect, false, true, this, 259);
}
{
core::rect<s32> rect(0, 0, 205, 20);
rect = rect + v2s32(70,50);
core::rect<s32> rect(0, 0, 340, 20);
rect = rect + v2s32(0,50);
v2u32 max_texture_size;
{
@ -131,47 +130,28 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize)
const s32 btn_num = 4;
s32 btn_y = (size.Y/2-((btn_num*btn_height+(btn_num-1)*btn_gap))/2)+40;
{
core::rect<s32> rect(0, 0, 140, btn_height);
rect = rect + v2s32(size.X/2-140/2, btn_y);
core::rect<s32> rect(0, 0, 180, btn_height);
rect = rect + v2s32(size.X/2-180/2, btn_y);
Environment->addButton(rect, this, 256, wgettext("Continue"));
}
btn_y += btn_height + btn_gap;
{
core::rect<s32> rect(0, 0, 140, btn_height);
rect = rect + v2s32(size.X/2-140/2, btn_y);
core::rect<s32> rect(0, 0, 180, btn_height);
rect = rect + v2s32(size.X/2-180/2, btn_y);
Environment->addButton(rect, this, 261, wgettext("Change Password"));
}
btn_y += btn_height + btn_gap;
{
core::rect<s32> rect(0, 0, 140, btn_height);
rect = rect + v2s32(size.X/2-140/2, btn_y);
core::rect<s32> rect(0, 0, 180, btn_height);
rect = rect + v2s32(size.X/2-180/2, btn_y);
Environment->addButton(rect, this, 260, wgettext("Disconnect"));
}
btn_y += btn_height + btn_gap;
{
core::rect<s32> rect(0, 0, 140, btn_height);
rect = rect + v2s32(size.X/2-140/2, btn_y);
core::rect<s32> rect(0, 0, 180, btn_height);
rect = rect + v2s32(size.X/2-180/2, btn_y);
Environment->addButton(rect, this, 257, wgettext("Exit to OS"));
}
//{
//core::rect<s32> rect(0, 0, 180, 240);
//rect = rect + v2s32(size.X/2 + 90, size.Y/2-rect.getHeight()/2);
//Environment->addStaticText(chartowchar_t(gettext(
//"Default Controls:\n"
//"- WASD: Walk\n"
//"- Mouse left: dig/hit\n"
//"- Mouse right: place/use\n"
//"- Mouse wheel: select item\n"
//"- 0...9: select item\n"
//"- Shift: sneak\n"
//"- R: Toggle viewing all loaded chunks\n"
//"- I: Inventory menu\n"
//"- ESC: This menu\n"
//"- T: Chat\n"
//)), rect, false, true, this, 258);
//}
changeCtype("C");
}
void GUIPauseMenu::drawMenu()

View File

@ -32,9 +32,11 @@
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include "gettext.h"
#include "gui_colours.h"
#if USE_FREETYPE
#include "intlGUIEditBox.h"
#endif
GUITextInputMenu::GUITextInputMenu(gui::IGUIEnvironment* env,
gui::IGUIElement* parent, s32 id,
@ -111,10 +113,13 @@ void GUITextInputMenu::regenerateGui(v2u32 screensize)
Add stuff
*/
{
//core::rect<s32> rect(0, 0, 300, 30);
//rect = rect + v2s32(size.X/2-300/2, size.Y/2-30/2-25);
core::rect<s32> rect(5, 0, 290, 30);
gui::IGUIElement *e = Environment->addEditBox(text.c_str(), rect, false, this, 256);
gui::IGUIEditBox *e;
#if USE_FREETYPE
e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(text.c_str(), true, Environment, this, 256, rect);
#else
e = Environment->addEditBox(text.c_str(), rect, false, this, 256);
#endif
Environment->setFocus(e);
@ -124,14 +129,6 @@ void GUITextInputMenu::regenerateGui(v2u32 screensize)
evt.KeyInput.PressedDown = true;
e->OnEvent(evt);
}
//changeCtype("");
//{
//core::rect<s32> rect(0, 0, 140, 30);
//rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25);
//Environment->addButton(rect, this, 257,
//wgettext("Write It"));
//}
//changeCtype("C");
}
void GUITextInputMenu::drawMenu()

1538
src/intlGUIEditBox.cpp Normal file

File diff suppressed because it is too large Load Diff

185
src/intlGUIEditBox.h Normal file
View File

@ -0,0 +1,185 @@
// Copyright (C) 2002-2013 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_INTL_GUI_EDIT_BOX_H_INCLUDED__
#define __C_INTL_GUI_EDIT_BOX_H_INCLUDED__
#include "IrrCompileConfig.h"
//#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIEditBox.h"
#include "irrArray.h"
#include "IOSOperator.h"
namespace irr
{
namespace gui
{
class intlGUIEditBox : public IGUIEditBox
{
public:
//! constructor
intlGUIEditBox(const wchar_t* text, bool border, IGUIEnvironment* environment,
IGUIElement* parent, s32 id, const core::rect<s32>& rectangle);
//! destructor
virtual ~intlGUIEditBox();
//! Sets another skin independent font.
virtual void setOverrideFont(IGUIFont* font=0);
//! Gets the override font (if any)
/** \return The override font (may be 0) */
virtual IGUIFont* getOverrideFont() const;
//! Get the font which is used right now for drawing
/** Currently this is the override font when one is set and the
font of the active skin otherwise */
virtual IGUIFont* getActiveFont() const;
//! Sets another color for the text.
virtual void setOverrideColor(video::SColor color);
//! Gets the override color
virtual video::SColor getOverrideColor() const;
//! Sets if the text should use the overide color or the
//! color in the gui skin.
virtual void enableOverrideColor(bool enable);
//! Checks if an override color is enabled
/** \return true if the override color is enabled, false otherwise */
virtual bool isOverrideColorEnabled(void) const;
//! Sets whether to draw the background
virtual void setDrawBackground(bool draw);
//! Turns the border on or off
virtual void setDrawBorder(bool border);
//! Enables or disables word wrap for using the edit box as multiline text editor.
virtual void setWordWrap(bool enable);
//! Checks if word wrap is enabled
//! \return true if word wrap is enabled, false otherwise
virtual bool isWordWrapEnabled() const;
//! Enables or disables newlines.
/** \param enable: If set to true, the EGET_EDITBOX_ENTER event will not be fired,
instead a newline character will be inserted. */
virtual void setMultiLine(bool enable);
//! Checks if multi line editing is enabled
//! \return true if mult-line is enabled, false otherwise
virtual bool isMultiLineEnabled() const;
//! Enables or disables automatic scrolling with cursor position
//! \param enable: If set to true, the text will move around with the cursor position
virtual void setAutoScroll(bool enable);
//! Checks to see if automatic scrolling is enabled
//! \return true if automatic scrolling is enabled, false if not
virtual bool isAutoScrollEnabled() const;
//! Gets the size area of the text in the edit box
//! \return Returns the size in pixels of the text
virtual core::dimension2du getTextDimension();
//! Sets text justification
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical);
//! called if an event happened.
virtual bool OnEvent(const SEvent& event);
//! draws the element and its children
virtual void draw();
//! Sets the new caption of this element.
virtual void setText(const wchar_t* text);
//! Sets the maximum amount of characters which may be entered in the box.
//! \param max: Maximum amount of characters. If 0, the character amount is
//! infinity.
virtual void setMax(u32 max);
//! Returns maximum amount of characters, previously set by setMax();
virtual u32 getMax() const;
//! Sets whether the edit box is a password box. Setting this to true will
/** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x
\param passwordBox: true to enable password, false to disable
\param passwordChar: the character that is displayed instead of letters */
virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*');
//! Returns true if the edit box is currently a password box.
virtual bool isPasswordBox() const;
//! Updates the absolute position, splits text if required
virtual void updateAbsolutePosition();
//! Writes attributes of the element.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
//! Reads attributes of the element
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
virtual bool isDrawBackgroundEnabled() const { return false; }
virtual bool isDrawBorderEnabled() const { return true; }
virtual void setCursorChar(const wchar_t cursorChar) { };
virtual wchar_t getCursorChar() const { return L'_'; };
virtual void setCursorBlinkTime(irr::u32 timeMs) { };
virtual irr::u32 getCursorBlinkTime() const { return 500; } ;
protected:
//! Breaks the single text line.
void breakText();
//! sets the area of the given line
void setTextRect(s32 line);
//! returns the line number that the cursor is on
s32 getLineFromPos(s32 pos);
//! adds a letter to the edit box
void inputChar(wchar_t c);
//! calculates the current scroll position
void calculateScrollPos();
//! send some gui event to parent
void sendGuiEvent(EGUI_EVENT_TYPE type);
//! set text markers
void setTextMarkers(s32 begin, s32 end);
bool processKey(const SEvent& event);
bool processMouse(const SEvent& event);
s32 getCursorPos(s32 x, s32 y);
bool MouseMarking;
bool Border;
bool OverrideColorEnabled;
s32 MarkBegin;
s32 MarkEnd;
video::SColor OverrideColor;
gui::IGUIFont *OverrideFont, *LastBreakFont;
IOSOperator* Operator;
u32 BlinkStartTime;
s32 CursorPos;
s32 HScrollPos, VScrollPos; // scroll position in characters
u32 Max;
bool WordWrap, MultiLine, AutoScroll, PasswordBox;
wchar_t PasswordChar;
EGUI_ALIGNMENT HAlign, VAlign;
core::array< core::stringw > BrokenText;
core::array< s32 > BrokenTextPositions;
core::rect<s32> CurrentTextRect, FrameRect; // temporary values
};
} // end namespace gui
} // end namespace irr
//#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_EDIT_BOX_H_INCLUDED__

View File

@ -1130,9 +1130,7 @@ int main(int argc, char *argv[])
// If font was not found, this will get us one
font = skin->getFont();
assert(font);
changeCtype("");
drawLoadingScreen(driver,wgettext("Setting Up UI"));
changeCtype("C");
u32 text_height = font->getDimension(L"Hello, world!").Height;
infostream<<"text_height="<<text_height<<std::endl;
@ -1155,13 +1153,9 @@ int main(int argc, char *argv[])
Preload some textures and stuff
*/
changeCtype("");
drawLoadingScreen(driver,wgettext("Loading MapNodes"));
changeCtype("C");
init_mapnode(driver); // Second call with g_texturesource set
changeCtype("");
drawLoadingScreen(driver,wgettext("Loading Creatures"));
changeCtype("C");
content_mob_init();
/*

View File

@ -271,45 +271,31 @@ void init_mapnode()
Initialize mapnode content
*/
#ifndef SERVER
changeCtype("");
drawLoadingScreen(driver,wgettext("Loading Base MapNodes"));
changeCtype("C");
#endif
content_mapnode_init(repeat);
#ifndef SERVER
changeCtype("");
drawLoadingScreen(driver,wgettext("Loading Circuit MapNodes"));
changeCtype("C");
#endif
content_mapnode_circuit(repeat);
#ifndef SERVER
changeCtype("");
drawLoadingScreen(driver,wgettext("Loading Plant MapNodes"));
changeCtype("C");
#endif
content_mapnode_plants(repeat);
#ifndef SERVER
changeCtype("");
drawLoadingScreen(driver,wgettext("Loading Farming MapNodes"));
changeCtype("C");
#endif
content_mapnode_farm(repeat);
#ifndef SERVER
changeCtype("");
drawLoadingScreen(driver,wgettext("Loading Decorative MapNodes"));
changeCtype("C");
#endif
content_mapnode_furniture(repeat);
#ifndef SERVER
changeCtype("");
drawLoadingScreen(driver,wgettext("Loading Interactive MapNodes"));
changeCtype("C");
#endif
content_mapnode_door(repeat);
#ifndef SERVER
changeCtype("");
drawLoadingScreen(driver,wgettext("Loading Special MapNodes"));
changeCtype("C");
#endif
content_mapnode_stair(repeat);
content_mapnode_slab(repeat);