Smartphone UI (finger-scrolling of level menu, bigger buttons, ...), several bugs fixed. Ignoring volume keys.Updated enigma-data32.zip included (modified some lua script).
This commit is contained in:
@@ -215,9 +215,14 @@ void Client::handle_events()
|
||||
on_mousebutton(e);
|
||||
break;
|
||||
case SDL_ACTIVEEVENT: {
|
||||
#ifdef ANDROID
|
||||
if (e.active.gain == 0)
|
||||
show_menu();
|
||||
#else
|
||||
update_mouse_button_state();
|
||||
if (e.active.gain == 0 && !video::IsFullScreen())
|
||||
show_menu();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -538,6 +543,17 @@ void Client::show_menu()
|
||||
enigma::gui::GameMenu(x, y).manage();
|
||||
}
|
||||
video::HideMouse();
|
||||
|
||||
#ifdef ANDROID
|
||||
SDL_Joystick *joy = SDL_JoystickOpen(0);
|
||||
SDL_JoystickUpdate();
|
||||
if(joy != NULL) {
|
||||
m_joy_x0 = SDL_JoystickGetAxis(joy,0);
|
||||
m_joy_y0 = SDL_JoystickGetAxis(joy,1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
update_mouse_button_state();
|
||||
if (m_state == cls_game)
|
||||
display::RedrawAll(screen);
|
||||
@@ -629,10 +645,9 @@ void Client::tick (double dtime)
|
||||
|
||||
case cls_preparing_game: {
|
||||
#ifdef ANDROID
|
||||
// calibrate the orientation sensor, using the current position as zero
|
||||
// TODO: average the values over some period of time?
|
||||
joy = SDL_JoystickOpen(0);
|
||||
SDL_JoystickUpdate();
|
||||
sdl::FlushEvents();
|
||||
if(joy != NULL) {
|
||||
m_joy_x0 = SDL_JoystickGetAxis(joy,0);
|
||||
m_joy_y0 = SDL_JoystickGetAxis(joy,1);
|
||||
@@ -664,7 +679,7 @@ void Client::tick (double dtime)
|
||||
joy_x = SDL_JoystickGetAxis(joy,0) - m_joy_x0;
|
||||
joy_y = SDL_JoystickGetAxis(joy,1) - m_joy_y0;
|
||||
server::Msg_MouseForce(options::GetDouble("MouseSpeed") * -dtime/3000.0 *
|
||||
V2 (joy_x*sqrt(abs(joy_x)), joy_y*sqrt(abs(joy_y)))); // use joy**1.5 to allow more flexible (non-linear) control
|
||||
V2 (-joy_x*sqrt(abs(joy_x)), -joy_y*sqrt(abs(joy_y)))); // use joy**1.5 to allow more flexible (non-linear) control
|
||||
}
|
||||
#endif
|
||||
if (app.state->getInt("NextLevelMode") == lev::NEXT_LEVEL_NOT_BEST) {
|
||||
|
||||
@@ -49,11 +49,11 @@ namespace enigma { namespace gui {
|
||||
info = new gui::StaticTextButton(N_("Level Info"), this);
|
||||
abort = new gui::StaticTextButton(N_("Abort Level"), this);
|
||||
|
||||
add(resume, Rect(0,0,180,40));
|
||||
add(restart, Rect(0,45,180,40));
|
||||
add(options, Rect(0,90,180,40));
|
||||
add(info, Rect(0,135,180,40));
|
||||
add(abort, Rect(0,180,180,40));
|
||||
add(resume, Rect(0,0,200,60));
|
||||
add(restart, Rect(0,70,200,60));
|
||||
add(options, Rect(0,140,200,60));
|
||||
add(info, Rect(0,210,200,60));
|
||||
add(abort, Rect(0,280,200,60));
|
||||
center();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace enigma { namespace gui {
|
||||
pgup = new ImageButton("ic-up", "ic-up1", this);
|
||||
pgdown = new ImageButton("ic-down", "ic-down1", this);
|
||||
|
||||
add(but_ok, Rect(vminfo.width-120, vminfo.height-60, 100, 40));
|
||||
add(pgup, Rect(vminfo.width-30, vminfo.height/2, 20, 50));
|
||||
add(pgdown, Rect(vminfo.width-30, vminfo.height/2 +70, 20, 50));
|
||||
add(but_ok, Rect(vminfo.width-130, vminfo.height-70, 120, 60));
|
||||
add(pgup, Rect(vminfo.width-45, vminfo.height/2 - 80, 40, 80));
|
||||
add(pgdown, Rect(vminfo.width-45, vminfo.height/2 + 30, 40, 80));
|
||||
}
|
||||
|
||||
void InfoMenu::draw_background(ecl::GC &gc) {
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace enigma { namespace gui {
|
||||
LevelMenuConfig (const ecl::Rect &screen)
|
||||
: buttonw (140), ibuttonw (90), buttonh (35),
|
||||
lbuttonw (140), lbuttonh (100),
|
||||
previewarea (10, 60, screen.w-50, screen.h-130),
|
||||
previewarea (10, 60, screen.w-10, screen.h-130),
|
||||
thumbsy (60),
|
||||
leftborder (10)
|
||||
{}
|
||||
@@ -105,6 +105,7 @@ namespace enigma { namespace gui {
|
||||
hl->add_back (hlr);
|
||||
this->add (hl, Rect(c.leftborder, Y3, vminfo.width-20, c.buttonh));
|
||||
|
||||
#ifndef ANDROID
|
||||
// Add navigation buttons
|
||||
pgup = new ImageButton("ic-up", "ic-up1", this);
|
||||
pgdown = new ImageButton("ic-down", "ic-down1", this);
|
||||
@@ -120,7 +121,7 @@ namespace enigma { namespace gui {
|
||||
add (start, r);
|
||||
r.y += 60;
|
||||
add (end, r);
|
||||
|
||||
#endif
|
||||
// Information area
|
||||
hl = new HList;
|
||||
hl->add_back (lbl_levelname, List::EXPAND);
|
||||
@@ -246,6 +247,7 @@ namespace enigma { namespace gui {
|
||||
} else if (w == but_back) {
|
||||
main_quit = true;
|
||||
Menu::quit();
|
||||
#ifndef ANDROID
|
||||
} else if (w == pgup) {
|
||||
levelwidget->page_up();
|
||||
} else if (w == pgdown) {
|
||||
@@ -254,6 +256,7 @@ namespace enigma { namespace gui {
|
||||
levelwidget->start();
|
||||
} else if (w == end) {
|
||||
levelwidget->end();
|
||||
#endif
|
||||
} else if (w == but_next) {
|
||||
next_unsolved();
|
||||
} else if (w == but_levelpack) {
|
||||
|
||||
@@ -57,7 +57,10 @@ namespace enigma { namespace gui {
|
||||
// Variables.
|
||||
|
||||
|
||||
#ifndef ANDROID
|
||||
Widget *pgup, *pgdown, *start, *end;
|
||||
#endif
|
||||
|
||||
Widget *but_advancemode; // Next unsolved level button
|
||||
Widget *but_next;
|
||||
Widget *but_back; // "Back" button
|
||||
|
||||
@@ -57,20 +57,16 @@ namespace enigma { namespace gui {
|
||||
vm = vminfo.videomode;
|
||||
|
||||
// Create buttons - positioning identical to Levelmenu
|
||||
but_new = new StaticTextButton(N_("New Group"), this);
|
||||
but_search = new StaticTextButton(N_("Search"), this);
|
||||
but_level = new StaticTextButton(N_("Start Game"), this);
|
||||
but_main = new StaticTextButton(N_("Main Menu"), this);
|
||||
|
||||
commandHList = new HList;
|
||||
commandHList->set_spacing(10);
|
||||
commandHList->set_spacing(60);
|
||||
commandHList->set_alignment(HALIGN_CENTER, VALIGN_TOP);
|
||||
commandHList->set_default_size(140, 35);
|
||||
commandHList->add_back(but_new);
|
||||
commandHList->add_back(but_search);
|
||||
commandHList->set_default_size(160, 50);
|
||||
commandHList->add_back(but_level);
|
||||
commandHList->add_back(but_main);
|
||||
this->add(commandHList, Rect(10, vminfo.height-50, vminfo.width-20, 35));
|
||||
this->add(commandHList, Rect(130, vminfo.height-70, vminfo.width-260, 50));
|
||||
|
||||
}
|
||||
|
||||
@@ -81,9 +77,9 @@ namespace enigma { namespace gui {
|
||||
int hmargin, hgroup_pack, hscrollbutton, hscroll_pack, hpack_pack;
|
||||
} param[video::VM_COUNT] = {
|
||||
{ // VM_640x480
|
||||
2, 9,
|
||||
2, 8,
|
||||
15, 10,
|
||||
20, 36, 22, 10, 20
|
||||
8, 36, 35, 10, 20
|
||||
},
|
||||
{ // VM_640x512
|
||||
2, 9,
|
||||
@@ -284,8 +280,8 @@ namespace enigma { namespace gui {
|
||||
if (needLeftScroll) {
|
||||
scrollLeft = new ImageButton("ic-left", "ic-left1", this);
|
||||
this->add(scrollLeft, Rect(param[vm].hmargin + 160 + param[vm].hgroup_pack,
|
||||
param[vm].vmargin + param[vm].rows / 2 * (35 + param[vm].vrow_row),
|
||||
param[vm].hscrollbutton, 35));
|
||||
param[vm].vmargin + param[vm].rows / 2 * (25 + param[vm].vrow_row),
|
||||
param[vm].hscrollbutton, 45));
|
||||
}
|
||||
|
||||
if (needRightScroll) {
|
||||
@@ -294,8 +290,8 @@ namespace enigma { namespace gui {
|
||||
param[vm].hscrollbutton + 2 * param[vm].hscroll_pack +
|
||||
param[vm].packcolumns * 160 + (param[vm].packcolumns - 1) *
|
||||
param[vm].hpack_pack,
|
||||
param[vm].vmargin + param[vm].rows / 2 * (35 + param[vm].vrow_row),
|
||||
param[vm].hscrollbutton, 35));
|
||||
param[vm].vmargin + param[vm].rows / 2 * (25 + param[vm].vrow_row),
|
||||
param[vm].hscrollbutton, 45));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,12 +345,6 @@ namespace enigma { namespace gui {
|
||||
void LevelPackMenu::on_action(Widget *w) {
|
||||
if (w == but_main) {
|
||||
Menu::quit();
|
||||
} else if (w == but_new) {
|
||||
LPGroupConfig m("");
|
||||
m.manage();
|
||||
setupMenu();
|
||||
updateHighlight();
|
||||
invalidate_all();
|
||||
} else if (w == but_level) {
|
||||
LevelMenu m;
|
||||
if (!m.manage() && isLevelMenuSubmenu || m.isMainQuit()) {
|
||||
@@ -364,22 +354,7 @@ namespace enigma { namespace gui {
|
||||
}
|
||||
setupMenu();
|
||||
updateHighlight();
|
||||
invalidate_all();
|
||||
} else if (w == but_search) {
|
||||
SearchMenu ml;
|
||||
ml.manage();
|
||||
if (ml.isSearchQuit()) {
|
||||
// show search result levelpack
|
||||
LevelMenu ml;
|
||||
if (!ml.manage() && isLevelMenuSubmenu || ml.isMainQuit()) {
|
||||
// ESC in LevelMenu in cade we are a submenu of LevelMenu or
|
||||
// Main button has been pressed in LevelMenu
|
||||
Menu::quit();
|
||||
}
|
||||
}
|
||||
setupMenu();
|
||||
updateHighlight();
|
||||
invalidate_all();
|
||||
invalidate_all();
|
||||
} else if (w == scrollUp) {
|
||||
firstDisplayedGroup--;
|
||||
reset_active_widget(); // we will delete it with setup
|
||||
|
||||
@@ -70,8 +70,6 @@ namespace enigma { namespace gui {
|
||||
ImageButton *scrollDown;
|
||||
VList *groupsVList;
|
||||
HList *commandHList;
|
||||
Widget *but_search;
|
||||
Widget *but_new;
|
||||
Widget *but_level;
|
||||
Widget *but_main;
|
||||
|
||||
|
||||
@@ -37,13 +37,14 @@ using namespace ecl;
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
namespace enigma { namespace gui {
|
||||
/* -------------------- LevelWidget -------------------- */
|
||||
|
||||
LevelWidget::LevelWidget(bool withScoreIcons, bool withEditBorder) :
|
||||
displayScoreIcons (withScoreIcons), displayEditBorder (withEditBorder),
|
||||
width (0), height (0), m_areas(),
|
||||
listener(0), isInvalidateUptodate (true), lastUpdate (0)
|
||||
listener(0), isInvalidateUptodate (true), lastUpdate (0), m_mousedown_x(-1), m_mousedown_y(-1)
|
||||
{
|
||||
const video::VMInfo &vminfo = *video::GetInfo();
|
||||
|
||||
@@ -192,8 +193,6 @@ namespace enigma { namespace gui {
|
||||
|
||||
if (!m_areas.empty()) {
|
||||
sound::EmitSoundEvent ("menumove");
|
||||
if (oldsel != newsel)
|
||||
sound::EmitSoundEvent ("menuswitch");
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
@@ -201,7 +200,6 @@ namespace enigma { namespace gui {
|
||||
iselected = newsel;
|
||||
|
||||
if (!m_areas.empty()) {
|
||||
sound::EmitSoundEvent ("menuswitch");
|
||||
invalidate_area(m_areas[oldsel-ifirst]); // old selection
|
||||
invalidate_area(m_areas[iselected-ifirst]); // new selection
|
||||
}
|
||||
@@ -212,11 +210,15 @@ namespace enigma { namespace gui {
|
||||
lev::Proxy *proxy, bool selected, bool isCross, bool locked,
|
||||
bool allowGeneration, bool &didGenerate) {
|
||||
// Draw button with level preview
|
||||
|
||||
|
||||
Surface *img = preview_cache->getPreview(proxy, allowGeneration, didGenerate);
|
||||
if (img == NULL)
|
||||
return false;
|
||||
|
||||
#ifdef ANDROID
|
||||
blit (gc, x-4, y-4, displayEditBorder ? img_editborder : img_border);
|
||||
blit (gc, x, y, img);
|
||||
#else
|
||||
if (selected) {
|
||||
blit (gc, x-4, y-4, displayEditBorder ? img_editborder : img_border);
|
||||
blit (gc, x, y, img);
|
||||
@@ -226,7 +228,7 @@ namespace enigma { namespace gui {
|
||||
blit (gc, x, y, img);
|
||||
img->set_alpha(255);
|
||||
}
|
||||
|
||||
#endif
|
||||
// Shade unavailable levels
|
||||
if (locked)
|
||||
blit (gc, x, y, img_unavailable);
|
||||
@@ -384,14 +386,19 @@ namespace enigma { namespace gui {
|
||||
switch (e.type) {
|
||||
case SDL_MOUSEMOTION:
|
||||
if (get_area().contains(e.motion.x, e.motion.y)) {
|
||||
int newsel=iselected;
|
||||
for (unsigned i=0; i<m_areas.size(); ++i)
|
||||
if (m_areas[i].contains(e.motion.x, e.motion.y))
|
||||
{
|
||||
newsel = ifirst+i;
|
||||
break;
|
||||
}
|
||||
set_current(newsel);
|
||||
int delta = e.motion.y - m_mousedown_y;
|
||||
if(abs(delta) > 75 && m_mousedown_y != -1) {
|
||||
m_mouse_drag = true;
|
||||
if(delta > 75)
|
||||
scroll_down(delta/75);
|
||||
else
|
||||
scroll_up(-delta/75);
|
||||
m_mousedown_y = e.motion.y;
|
||||
} else if(m_mousedown_y == -1) {
|
||||
m_mouse_drag = true;
|
||||
m_mousedown_x = e.motion.x;
|
||||
m_mousedown_y = e.motion.y;
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
@@ -399,6 +406,12 @@ namespace enigma { namespace gui {
|
||||
if (get_area().contains(e.button.x, e.button.y))
|
||||
handled = handle_mousedown (&e);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
if (get_area().contains(e.button.x, e.button.y))
|
||||
handled = handle_mouseup (&e);
|
||||
m_mousedown_x = m_mousedown_y = -1;
|
||||
m_mouse_drag = false;
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
handled = handle_keydown (&e);
|
||||
break;
|
||||
@@ -409,8 +422,18 @@ namespace enigma { namespace gui {
|
||||
|
||||
bool LevelWidget::handle_mousedown (const SDL_Event *e)
|
||||
{
|
||||
switch (e->button.button) {
|
||||
case SDL_BUTTON_LEFT:
|
||||
if(e->button.button == SDL_BUTTON_LEFT) {
|
||||
m_mousedown_x = e->button.x;
|
||||
m_mousedown_y = e->button.y;
|
||||
m_mouse_drag = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LevelWidget::handle_mouseup (const SDL_Event *e)
|
||||
{
|
||||
if(e->button.button == SDL_BUTTON_LEFT && !m_mouse_drag && abs(m_mousedown_x-e->button.x) < 15 && abs(m_mousedown_y-e->button.y) < 15) {
|
||||
for (unsigned i=0; i<m_areas.size(); ++i)
|
||||
if (m_areas[i].contains(e->button.x, e->button.y))
|
||||
{
|
||||
@@ -428,26 +451,11 @@ namespace enigma { namespace gui {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
for (unsigned i=0; i<m_areas.size(); ++i)
|
||||
if (m_areas[i].contains(e->button.x, e->button.y))
|
||||
{
|
||||
sound::EmitSoundEvent ("menuok");
|
||||
iselected = ifirst+i;
|
||||
syncToIndexMgr();
|
||||
LevelInspector m(curIndex->getProxy(iselected));
|
||||
m.manage();
|
||||
get_parent()->draw_all();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 4: scroll_down(1); return true;
|
||||
case 5: scroll_up(1); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool LevelWidget::handle_keydown (const SDL_Event *e)
|
||||
{
|
||||
switch (e->key.keysym.sym) {
|
||||
|
||||
@@ -71,6 +71,7 @@ namespace enigma { namespace gui {
|
||||
|
||||
bool handle_keydown (const SDL_Event *e);
|
||||
bool handle_mousedown (const SDL_Event *e);
|
||||
bool handle_mouseup (const SDL_Event *e);
|
||||
|
||||
//---------- Variables ----------//
|
||||
bool displayScoreIcons;
|
||||
@@ -80,6 +81,10 @@ namespace enigma { namespace gui {
|
||||
lev::Index *curIndex;
|
||||
ActionListener *listener;
|
||||
|
||||
int m_mousedown_x;
|
||||
int m_mousedown_y;
|
||||
bool m_mouse_drag;
|
||||
|
||||
int ifirst; // Index of "upper left" level
|
||||
int iselected; // Index of selected level
|
||||
int width; // number of buttons in a row
|
||||
|
||||
@@ -154,6 +154,8 @@ namespace enigma { namespace gui {
|
||||
" Clifford J. Tasner (Music second generation, Proof reading)",
|
||||
0,
|
||||
N_("Contributors:"),
|
||||
" Michi (Android Port, Smartphone UI)",
|
||||
" pelya (libsdl-android)",
|
||||
" Roberto Bardin (Level design)",
|
||||
" Alain Busser (Level design, French translation, manual)",
|
||||
" Guy Busser (Level design)",
|
||||
@@ -213,18 +215,16 @@ namespace enigma { namespace gui {
|
||||
|
||||
void MainMenu::build_menu()
|
||||
{
|
||||
const video::VMInfo *vminfo = video::GetInfo();
|
||||
|
||||
BuildVList b(this, Rect((vminfo->width - 150)/2,150,150,40), 5);
|
||||
BuildVList b(this, Rect(100,150,180,80), 20);
|
||||
m_startgame = b.add(new StaticTextButton(N_("Start Game"), this));
|
||||
m_levelpack = b.add(new StaticTextButton(N_("Level Pack"), this));
|
||||
#ifdef ENABLE_EXPERIMENTAL
|
||||
m_netgame = b.add (new StaticTextButton (N_("Network Game"), this));
|
||||
leveled = b.add(new StaticTextButton(N_("Editor"), this));
|
||||
#endif
|
||||
options = b.add(new StaticTextButton(N_("Options"), this));
|
||||
credits = b.add(new StaticTextButton(N_("Credits"), this));
|
||||
quit = b.add(new StaticTextButton(N_("Quit"), this));
|
||||
|
||||
BuildVList c(this, Rect(340,150,180,80), 20);
|
||||
options = c.add(new StaticTextButton(N_("Options"), this));
|
||||
credits = c.add(new StaticTextButton(N_("Credits"), this));
|
||||
|
||||
BuildVList d(this, Rect(230,360,180,80), 20);
|
||||
quit = d.add(new StaticTextButton(N_("Quit"), this));
|
||||
}
|
||||
|
||||
void MainMenu::draw_background(ecl::GC &gc)
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <SDL/SDL_mixer.h>
|
||||
#endif
|
||||
|
||||
using namespace ecl;
|
||||
using namespace std;
|
||||
@@ -34,6 +37,28 @@ using namespace std;
|
||||
#define SCREEN ecl::Screen::get_instance()
|
||||
|
||||
namespace enigma { namespace gui {
|
||||
|
||||
#ifdef ANDROID
|
||||
static bool playingMenuMusic = false;
|
||||
|
||||
static void appPutToBackgroundCallbackMenu(void) {
|
||||
playingMenuMusic = false;
|
||||
|
||||
if(Mix_PlayingMusic()) {
|
||||
playingMenuMusic = true;
|
||||
Mix_PauseMusic();
|
||||
}
|
||||
}
|
||||
|
||||
static void appRestoredCallbackMenu(void) {
|
||||
if(playingMenuMusic) {
|
||||
playingMenuMusic = false;
|
||||
Mix_ResumeMusic();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* -------------------- Menu -------------------- */
|
||||
|
||||
Menu::Menu()
|
||||
@@ -65,6 +90,12 @@ namespace enigma { namespace gui {
|
||||
Uint32 enterTickTime = SDL_GetTicks(); // protection against ESC D.o.S. attacks
|
||||
while (SDL_PollEvent(&e)) {} // clear event queue
|
||||
draw_all();
|
||||
#ifdef ANDROID
|
||||
int repaintCounter = 0;
|
||||
playingMenuMusic = false;
|
||||
SDL_ANDROID_SetApplicationPutToBackgroundCallback(appPutToBackgroundCallbackMenu, appRestoredCallbackMenu);
|
||||
#endif
|
||||
|
||||
while (!(quitp || abortp)) {
|
||||
SCREEN->flush_updates();
|
||||
while (SDL_PollEvent(&e)) {
|
||||
@@ -73,6 +104,12 @@ namespace enigma { namespace gui {
|
||||
SDL_Delay(10);
|
||||
if(active_widget) active_widget->tick(0.01);
|
||||
tick (0.01);
|
||||
#ifdef ANDROID
|
||||
// repaint, needed if the app was restored
|
||||
if(repaintCounter++ > 20) {
|
||||
invalidate_all(); repaintCounter = 0;
|
||||
}
|
||||
#endif
|
||||
refresh();
|
||||
}
|
||||
sound::EmitSoundEvent ("menuexit");
|
||||
@@ -112,6 +149,7 @@ namespace enigma { namespace gui {
|
||||
|
||||
void Menu::handle_event(const SDL_Event &e)
|
||||
{
|
||||
|
||||
if (e.type == SDL_KEYDOWN &&
|
||||
e.key.keysym.sym == SDLK_RETURN &&
|
||||
e.key.keysym.mod & KMOD_ALT)
|
||||
|
||||
@@ -315,74 +315,39 @@ namespace enigma { namespace gui {
|
||||
|
||||
OptionsMenu::OptionsMenu(ecl::Surface *background_)
|
||||
: back(new StaticTextButton(N_("Back"), this)),
|
||||
fullscreen(new FullscreenButton),
|
||||
m_restartinfo (new Label("")),
|
||||
background(background_),
|
||||
previous_caption(video::GetCaption())
|
||||
{
|
||||
const int spacing = 5;
|
||||
const int big_spacing = 60;
|
||||
const int spacing = 10;
|
||||
const int label_width = 180;
|
||||
const int but_width = 100;
|
||||
const int but_height = 30;
|
||||
const int but_height = 70;
|
||||
const video::VMInfo *vminfo = video::GetInfo();
|
||||
int hmargin = vminfo->width < 660 ? 10 : (vminfo->width < 900 ? 20 : 80);
|
||||
int midspacing = vminfo->width - 2*hmargin - 2*but_width - 2*label_width;
|
||||
|
||||
BuildVList leftlabels (this, Rect(-label_width, 0, label_width, but_height), spacing);
|
||||
BuildVList left (this, Rect(0, 0, but_width, but_height), spacing);
|
||||
// BuildVList left (this, Rect(0, 0, but_width, but_height), spacing);
|
||||
BuildVList rightlabels (this, Rect(but_width+midspacing, 0, label_width, but_height), spacing);
|
||||
BuildVList right(this, Rect(but_width+midspacing+label_width, 0, but_width, but_height), spacing);
|
||||
leftlabels.add (new Label(N_("Language: "), HALIGN_RIGHT));
|
||||
leftlabels.add (new Label(N_("Fullscreen: "), HALIGN_RIGHT));
|
||||
leftlabels.add (new Label(N_("Video mode: "), HALIGN_RIGHT));
|
||||
leftlabels.add (new Label(N_("Gamma correction: "), HALIGN_RIGHT));
|
||||
leftlabels.add (new Label(N_("Mouse speed: "), HALIGN_RIGHT));
|
||||
|
||||
language = new LanguageButton(this);
|
||||
left.add (language);
|
||||
left.add (fullscreen);
|
||||
left.add (new VideoModeButton);
|
||||
left.add (new GammaButton);
|
||||
left.add (new MouseSpeedButton);
|
||||
|
||||
rightlabels.add (new Label(N_("Sound volume: "), HALIGN_RIGHT));
|
||||
rightlabels.add (new Label(N_("Sound set: "), HALIGN_RIGHT));
|
||||
rightlabels.add (new Label(N_("Music volume: "), HALIGN_RIGHT));
|
||||
rightlabels.add (new Label(N_("Stereo: "), HALIGN_RIGHT));
|
||||
rightlabels.add (new Label(N_("Ratings update: "), HALIGN_RIGHT));
|
||||
|
||||
right.add (new SoundVolumeButton);
|
||||
right.add (new SoundSetButton);
|
||||
right.add (new MusicVolumeButton);
|
||||
// right.add (new InGameMusicButton);Über
|
||||
right.add (new StereoButton);
|
||||
right.add (new RatingsUpdateButton);
|
||||
// BuildVList right(this, Rect(but_width+midspacing+label_width, 0, but_width, but_height), spacing);
|
||||
leftlabels.add (new Label(N_("Tilt sensitivity: "),HALIGN_CENTER,VALIGN_BOTTOM));
|
||||
leftlabels.add (new MouseSpeedButton);
|
||||
|
||||
leftlabels.add (new Label(N_("Ratings update: "),HALIGN_CENTER,VALIGN_BOTTOM));
|
||||
leftlabels.add (new RatingsUpdateButton);
|
||||
|
||||
rightlabels.add (new Label(N_("Sound volume: "),HALIGN_CENTER,VALIGN_BOTTOM));
|
||||
rightlabels.add (new SoundVolumeButton);
|
||||
|
||||
rightlabels.add (new Label(N_("Music volume: "),HALIGN_CENTER,VALIGN_BOTTOM));
|
||||
rightlabels.add (new MusicVolumeButton);
|
||||
|
||||
Rect l = left.pos();
|
||||
Rect r = right.pos();
|
||||
Rect l = leftlabels.pos();
|
||||
Rect r = rightlabels.pos();
|
||||
|
||||
BuildVList bottomlabels (this, Rect(-label_width, Max(l.y, r.y), label_width, but_height), spacing);
|
||||
BuildVList bottom (this, Rect(0, Max(l.y, r.y), vminfo->width - 2*hmargin - label_width, but_height), spacing);
|
||||
bottomlabels.add (new Label(N_("User name: "), HALIGN_RIGHT));
|
||||
bottomlabels.add (new Label(N_("User path: "), HALIGN_RIGHT));
|
||||
bottomlabels.add (new Label(N_("User image path: "), HALIGN_RIGHT));
|
||||
userNameTF = new TextField(app.state->getString("UserName"));
|
||||
userNameTF->setMaxChars(20);
|
||||
userNameTF->setInvalidChars("+");
|
||||
bottom.add (userNameTF);
|
||||
userPathTF = new TextField(XMLtoUtf8(LocalToXML(app.userPath.c_str()).x_str()).c_str());
|
||||
bottom.add (userPathTF);
|
||||
userImagePathTF = new TextField(XMLtoUtf8(LocalToXML(app.userImagePath.c_str()).x_str()).c_str());
|
||||
bottom.add (userImagePathTF);
|
||||
|
||||
// add (m_restartinfo, Rect (l.x, l.y + 15, 400, 20));
|
||||
// m_restartinfo->set_alignment (HALIGN_LEFT);
|
||||
// update_info();
|
||||
|
||||
Rect b = bottom.pos();
|
||||
l.x = (l.x+r.x)/2;
|
||||
l.y = b.y+big_spacing;
|
||||
l.y = 380;
|
||||
|
||||
add(back, l);
|
||||
}
|
||||
@@ -391,33 +356,7 @@ namespace enigma { namespace gui {
|
||||
video::SetCaption(previous_caption.c_str());
|
||||
}
|
||||
|
||||
// void OptionsMenu::update_info()
|
||||
// {
|
||||
// if (options::MustRestart)
|
||||
// m_restartinfo->set_text (
|
||||
// N_("Please restart Enigma to activate your changes!"));
|
||||
// else
|
||||
// m_restartinfo->set_text ("");
|
||||
// }
|
||||
|
||||
void OptionsMenu::quit() {
|
||||
std::string tfUserPathLocal = XMLtoLocal(Utf8ToXML(userPathTF->getText().c_str()).x_str()).c_str();
|
||||
std::string tfUserImageLocal = XMLtoLocal(Utf8ToXML(userImagePathTF->getText().c_str()).x_str()).c_str();
|
||||
if ((app.state->getString("UserName") != userNameTF->getText())
|
||||
|| (app.userPath != tfUserPathLocal ) || (app.userImagePath != tfUserImageLocal)) {
|
||||
// ensure that enigma.score is saved with new Username or to new location
|
||||
lev::ScoreManager::instance()->markModified();
|
||||
}
|
||||
// strip off leading and trailing whitespace from user name
|
||||
std::string userName = userNameTF->getText();
|
||||
std::string::size_type firstChar = userName.find_first_not_of(" ");
|
||||
std::string::size_type lastChar = userName.find_last_not_of(" ");
|
||||
if (firstChar != std::string::npos)
|
||||
app.state->setProperty("UserName", userName.substr(firstChar, lastChar - firstChar + 1));
|
||||
else
|
||||
app.state->setProperty("UserName", std::string(""));
|
||||
app.setUserPath(tfUserPathLocal.c_str());
|
||||
app.setUserImagePath(tfUserImageLocal.c_str());
|
||||
Menu::quit();
|
||||
}
|
||||
|
||||
@@ -430,15 +369,6 @@ namespace enigma { namespace gui {
|
||||
quit();
|
||||
handled = true;
|
||||
}
|
||||
else if (e.type == SDL_KEYUP) {
|
||||
if ((e.key.keysym.sym==SDLK_RETURN) &&
|
||||
(e.key.keysym.mod & KMOD_ALT))
|
||||
{
|
||||
// update state of FullscreenButton :
|
||||
fullscreen->invalidate();
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
@@ -446,20 +376,15 @@ namespace enigma { namespace gui {
|
||||
{
|
||||
if (w == back)
|
||||
quit();
|
||||
else if (w == language)
|
||||
// language changed - retranslate and redraw everything
|
||||
invalidate_all();
|
||||
}
|
||||
|
||||
void OptionsMenu::tick (double)
|
||||
{
|
||||
// update_info();
|
||||
}
|
||||
|
||||
void OptionsMenu::draw_background(ecl::GC &gc)
|
||||
{
|
||||
video::SetCaption(("Enigma - Options Menu"));
|
||||
// blit(gc, 0,0, enigma::GetImage("menu_bg"));
|
||||
blit(gc, 0,0, background);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,10 +42,7 @@ namespace enigma { namespace gui {
|
||||
void tick(double dtime);
|
||||
|
||||
// Variables.
|
||||
gui::Widget *back, *fullscreen, *language;
|
||||
gui::TextField *userNameTF;
|
||||
gui::TextField *userPathTF;
|
||||
gui::TextField *userImagePathTF;
|
||||
gui::Widget *back;
|
||||
gui::Label *m_restartinfo;
|
||||
ecl::Surface *background;
|
||||
std::string previous_caption;
|
||||
|
||||
@@ -603,9 +603,11 @@ Button::Button() : m_activep (false), highlight (false) {
|
||||
|
||||
void Button::activate()
|
||||
{
|
||||
#ifndef ANDROID
|
||||
sound::EmitSoundEvent ("menuswitch");
|
||||
m_activep = true;
|
||||
invalidate();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Button::deactivate() {
|
||||
@@ -765,8 +767,8 @@ ecl::Font *TextButton::menufont_pressed = 0;
|
||||
|
||||
TextButton::TextButton(ActionListener *al) {
|
||||
if (menufont == 0) {
|
||||
menufont = enigma::GetFont("menufont");
|
||||
menufont_pressed = enigma::GetFont("menufontsel");
|
||||
menufont = enigma::GetFont("buttonfont");
|
||||
menufont_pressed = enigma::GetFont("buttonfont");
|
||||
}
|
||||
set_listener(al);
|
||||
}
|
||||
|
||||
@@ -378,9 +378,11 @@ void Application::init(int argc, char **argv)
|
||||
INDEX_EVERY_GROUP, ap.levelnames, INDEX_STARTUP_PACK_LOCATION));
|
||||
lev::Index::setCurrentIndex(INDEX_STARTUP_PACK_NAME);
|
||||
}
|
||||
#ifndef ANDROID
|
||||
std::vector<std::string> emptyList;
|
||||
lev::Index::registerIndex(new lev::VolatileIndex(INDEX_SEARCH_PACK_NAME,
|
||||
INDEX_DEFAULT_GROUP, emptyList, INDEX_SEARCH_PACK_LOCATION));
|
||||
#endif
|
||||
}
|
||||
|
||||
lev::Proxy::countLevels();
|
||||
|
||||
Reference in New Issue
Block a user