From 28aea581e7b7fcc5a01c7d79b2016171372d574c Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Fri, 1 Jan 2010 09:30:05 +0000 Subject: [PATCH] Get the network preferences from the mock prefs implementation --- Makefile | 4 ++-- gui.cpp | 6 ++++++ gui.hh | 6 ++++++ mocks/Prefs.h | 10 ++++++++++ network_menu.cpp | 28 +++++++++++----------------- 5 files changed, 35 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 858bfff..a1482d2 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ OBJS=menu.oo main.oo utils.oo gui.oo dialogue_box.oo menu_messages.oo \ all: menu %.oo: %.cpp - g++ -Wall -g -c `sdl-config --cflags` -o $@ $< + g++ -Imocks -Wall -g -c `sdl-config --cflags` -o $@ $< menu.oo: menu.cpp menu.hh utils.hh font.hh widget.hh Makefile @@ -13,7 +13,7 @@ widget.oo: widget.cpp widget.hh gui.oo: gui.cpp gui.hh Makefile font.hh menu.hh sdl_ttf_font.hh \ dialogue_box.hh help_box.hh main_menu.cpp disc_menu.cpp \ file_browser.hh timer.hh game_info.hh widget.hh options_menu.cpp \ - network_menu.cpp + network_menu.cpp mocks/Prefs.h virtual_keyboard.oo: virtual_keyboard.hh virtual_keyboard.cpp widget.hh listener.hh diff --git a/gui.cpp b/gui.cpp index b54dcb1..198ac0b 100644 --- a/gui.cpp +++ b/gui.cpp @@ -52,6 +52,8 @@ void GuiView::viewPopCallback() Gui::Gui() { + this->np = NULL; + this->focus = NULL; this->bg_left = NULL; @@ -255,10 +257,14 @@ void Gui::draw(SDL_Surface *where) void Gui::activate() { this->is_active = true; + /* FIXME! TMP! TMP! */ + this->np = new Prefs(); } void Gui::deActivate() { + /* FIXME! TMP! TMP! */ + delete this->np; this->is_active = false; } diff --git a/gui.hh b/gui.hh index 0541aa2..178f301 100644 --- a/gui.hh +++ b/gui.hh @@ -8,6 +8,9 @@ #include "timer.hh" #include "gui_view.hh" +/* Frodo stuff */ +#include + class MainView; class DialogueBox; class DiscView; @@ -91,6 +94,9 @@ public: const char *theme_base_path; const char *game_base_path; + /* New preferences */ + Prefs *np; + /* Singleton */ static void init(); static Gui *gui; diff --git a/mocks/Prefs.h b/mocks/Prefs.h index 7035693..d387a7c 100644 --- a/mocks/Prefs.h +++ b/mocks/Prefs.h @@ -1,8 +1,18 @@ #ifndef __MOCK_PREFS_HH__ #define __MOCK_PREFS_HH__ +#include + class Prefs { +public: + Prefs() + { + strcpy(this->NetworkName, "Unset name"); + strcpy(this->NetworkServer, "play.c64-network.org"); + this->NetworkPort = 46214; + } + char NetworkName[32]; char NetworkServer[128]; int NetworkPort; diff --git a/network_menu.cpp b/network_menu.cpp index b000c2f..02d226c 100644 --- a/network_menu.cpp +++ b/network_menu.cpp @@ -11,7 +11,8 @@ public: NetworkMenu(Font *font, HelpBox *help) : Menu(font) { this->help = help; - this->updateMessages(); + memset(this->messages, 0, sizeof(this->messages)); + memset(this->strs, 0, sizeof(this->strs)); } ~NetworkMenu() @@ -23,19 +24,7 @@ public: printf("option entry %d selected: %s\n", which, this->pp_msgs[which]); switch (which) { - case 0: /* Insert disc */ - break; - case 2: /* Load/save states */ - break; - case 4: /* Keyboard */ - break; - case 7: /* Reset the C64 */ - break; - case 8: /* Networking */ - break; - case 9: /* Options */ - break; - case 10: /* Help */ + default: break; } } @@ -55,11 +44,11 @@ private: { memset(this->strs, 0, sizeof(this->strs)); snprintf(this->strs[0], sizeof(this->strs[0]) - 1, "Set username (%s)", - "Vobb"); // FIXME! + Gui::gui->np->NetworkName); snprintf(this->strs[1], sizeof(this->strs[1]) - 1, "Server (%s)", - "play.c64-network.org"); // FIXME! + Gui::gui->np->NetworkServer); snprintf(this->strs[2], sizeof(this->strs[2]) - 1, "Server port (%d)", - 46214); // FIXME! + Gui::gui->np->NetworkPort); this->messages[0] = this->strs[0]; this->messages[1] = this->strs[1]; @@ -114,6 +103,11 @@ public: this->menu->pushEvent(ev); } + void viewPushCallback() + { + this->menu->updateMessages(); + } + void draw(SDL_Surface *where) { SDL_Rect dst;