fixed menu switching problems and some compile errors

This commit is contained in:
Magnus Auvinen 2007-11-18 22:20:35 +00:00
parent b44a3edfe9
commit d66a2a46ef
7 changed files with 39 additions and 22 deletions

View file

@ -31,7 +31,7 @@
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <shlobj.h> // for SHGetFolderPathAndSubDir
#include <shlobj.h> /* for SHGetFolderPathAndSubDir */
#include <fcntl.h>
#include <direct.h>
#include <errno.h>

View file

@ -10,7 +10,7 @@ enum
MAX_SKINS=256,
};
static skin skins[MAX_SKINS] = {0};
static skin skins[MAX_SKINS] = {{0}};
static int num_skins = 0;
static void skinscan(const char *name, int is_dir, void *user)

View file

@ -41,6 +41,7 @@ enum
static int chat_mode = CHATMODE_NONE;
bool menu_active = false;
bool menu_game_active = false;
static bool emoticon_selector_active = false;
static vec2 mouse_pos;
@ -959,7 +960,7 @@ static void render_flag(const obj_flag *prev, const obj_flag *current)
vec2 pos = mix(vec2(prev->x, prev->y), vec2(current->x, current->y), client_intratick());
if(current->local_carry)
if(local_info && current->carried_by == local_info->clientid)
pos = local_character_pos;
gfx_setcolor(current->team ? 0 : 1,0,current->team ? 1 : 0,1);
@ -1989,7 +1990,11 @@ void render_game()
if (chat_mode)
chat_mode = CHATMODE_NONE;
else
{
menu_active = !menu_active;
if(menu_active)
menu_game_active = true;
}
}
// handle chat input
@ -2610,12 +2615,19 @@ void menu_do_connected();
extern "C" void modc_statechange(int state, int old)
{
if(state == CLIENTSTATE_OFFLINE)
{
menu_do_disconnected();
menu_game_active = false;
}
if(state == CLIENTSTATE_CONNECTING)
menu_do_connecting();
if (state == CLIENTSTATE_ONLINE)
{
menu_active = false;
menu_game_active = true;
menu_do_connected();
}
}
extern "C" void modc_message(int msg)
{
@ -2703,8 +2715,6 @@ extern "C" void modc_connected()
killmsgs[i].tick = -100000;
send_info(true);
config.ui_page = 5;
}
extern "C" const char *modc_net_version() { return TEEWARS_NETVERSION; }

View file

@ -30,6 +30,7 @@ extern data_container *data;
// abit uglyness
extern const obj_player_info *local_info;
extern bool menu_active;
extern bool menu_game_active;
//static vec4 gui_color(0.9f,0.78f,0.65f, 0.5f);
@ -68,7 +69,7 @@ enum
PAGE_LAN,
PAGE_FAVORITES,
PAGE_SETTINGS,
PAGE_GAME,
//PAGE_GAME, // not a real page
PAGE_SYSTEM,
};
@ -649,13 +650,18 @@ static int menu2_render_menubar(RECT r)
RECT box = r;
RECT button;
int current_page = config.ui_page;
int active_page = config.ui_page;
if(menu_game_active)
active_page = -1;
if(client_state() == CLIENTSTATE_OFFLINE)
{
if(0) // this is not done yet
{
ui2_vsplit_l(&box, 90.0f, &button, &box);
static int news_button=0;
if (ui2_do_button(&news_button, "News", config.ui_page==PAGE_NEWS, &button, ui2_draw_menu_tab_button, 0))
if (ui2_do_button(&news_button, "News", active_page==PAGE_NEWS, &button, ui2_draw_menu_tab_button, 0))
config.ui_page = PAGE_NEWS;
ui2_vsplit_l(&box, 30.0f, 0, &box);
}
@ -664,14 +670,15 @@ static int menu2_render_menubar(RECT r)
{
ui2_vsplit_l(&box, 90.0f, &button, &box);
static int game_button=0;
if (ui2_do_button(&game_button, "Game", config.ui_page==PAGE_GAME, &button, ui2_draw_menu_tab_button, 0))
config.ui_page = PAGE_GAME;
if (ui2_do_button(&game_button, "Game", menu_game_active, &button, ui2_draw_menu_tab_button, 0))
menu_game_active = true;
ui2_vsplit_l(&box, 30.0f, 0, &box);
}
ui2_vsplit_l(&box, 110.0f, &button, &box);
static int internet_button=0;
if (ui2_do_button(&internet_button, "Internet", config.ui_page==PAGE_INTERNET, &button, ui2_draw_menu_tab_button, 0))
if (ui2_do_button(&internet_button, "Internet", active_page==PAGE_INTERNET, &button, ui2_draw_menu_tab_button, 0))
{
client_serverbrowse_refresh(0);
config.ui_page = PAGE_INTERNET;
@ -680,7 +687,7 @@ static int menu2_render_menubar(RECT r)
ui2_vsplit_l(&box, 4.0f, 0, &box);
ui2_vsplit_l(&box, 90.0f, &button, &box);
static int lan_button=0;
if (ui2_do_button(&lan_button, "LAN", config.ui_page==PAGE_LAN, &button, ui2_draw_menu_tab_button, 0))
if (ui2_do_button(&lan_button, "LAN", active_page==PAGE_LAN, &button, ui2_draw_menu_tab_button, 0))
{
client_serverbrowse_refresh(1);
config.ui_page = PAGE_LAN;
@ -691,7 +698,7 @@ static int menu2_render_menubar(RECT r)
ui2_vsplit_l(&box, 4.0f, 0, &box);
ui2_vsplit_l(&box, 120.0f, &button, &box);
static int favorites_button=0;
if (ui2_do_button(&favorites_button, "Favorites", config.ui_page==PAGE_FAVORITES, &button, ui2_draw_menu_tab_button, 0))
if (ui2_do_button(&favorites_button, "Favorites", active_page==PAGE_FAVORITES, &button, ui2_draw_menu_tab_button, 0))
config.ui_page = PAGE_FAVORITES;
}
@ -705,9 +712,12 @@ static int menu2_render_menubar(RECT r)
*/
ui2_vsplit_r(&box, 110.0f, &box, &button);
static int settings_button=0;
if (ui2_do_button(&settings_button, "Settings", config.ui_page==PAGE_SETTINGS, &button, ui2_draw_menu_tab_button, 0))
if (ui2_do_button(&settings_button, "Settings", active_page==PAGE_SETTINGS, &button, ui2_draw_menu_tab_button, 0))
config.ui_page = PAGE_SETTINGS;
if(current_page != config.ui_page)
menu_game_active = false;
return 0;
}
@ -1380,8 +1390,6 @@ static void menu2_render_game(RECT main_view)
if(ui2_do_button(&disconnect_button, "Disconnect", 0, &button, ui2_draw_menu_button, 0))
client_disconnect();
if(local_info)
{
if(local_info->team != -1)
@ -1487,7 +1495,7 @@ int menu2_render()
//ui2_hsplit_b(&main_view, 26.0f, &main_view, &bottom_bar);
// render current page
if(config.ui_page == PAGE_GAME)
if(menu_game_active)
menu2_render_game(main_view);
else if(config.ui_page == PAGE_NEWS)
menu2_render_news(main_view);

View file

@ -160,7 +160,7 @@ struct obj_flag
{
int x, y;
int team;
int local_carry; // is set if the local player has the flag
int carried_by; // is set if the local player has the flag
};
// core object needed for physics

View file

@ -46,7 +46,7 @@ MACRO_CONFIG_STR(player_skin, 64, "default")
MACRO_CONFIG_INT(dbg_new_gui, 0, 0, 1)
MACRO_CONFIG_INT(ui_page, 0, 0, 5)
MACRO_CONFIG_INT(ui_page, 1, 0, 5)
MACRO_CONFIG_STR(ui_server_address, 128, "localhost:8303")

View file

@ -129,9 +129,8 @@ void flag::snap(int snapping_client)
flag->x = (int)pos.x;
flag->y = (int)pos.y;
flag->team = team;
flag->carried_by = -1;
if(carrying_player && carrying_player->client_id == snapping_client)
flag->local_carry = 1;
else
flag->local_carry = 0;
if(carrying_player)
flag->carried_by = carrying_player->client_id;
}