new gui commit

This commit is contained in:
Magnus Auvinen 2007-11-04 21:36:03 +00:00
parent daf89a01ff
commit b6a629cf80
11 changed files with 1166 additions and 28 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

@ -27,7 +27,7 @@ def get_nick():
return nicks[inick].replace("`", "\`")
for s in xrange(0, 150):
cmd = "./fake_server_d "
cmd = "./fake_server_d_d "
cmd += '-n "%s" ' % (random.choice(servernames) % get_nick())
for m in masterservers:
cmd += '-m %s '%m

View file

@ -686,7 +686,7 @@ static int editor_reset()
return 0;
}
void draw_editor_button(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra)
void draw_editor_button(const void *id, const char *text, int checked, float x, float y, float w, float h, void *extra)
{
gfx_blend_normal();
gfx_texture_set(-1);

View file

@ -48,6 +48,7 @@ static VOICE voices[NUM_VOICES] = { {0} };
static CHANNEL channels[NUM_CHANNELS] = { {255, 0} };
static LOCK sound_lock = 0;
static int sound_enabled = 0;
static int center_x = 0;
static int center_y = 0;
@ -231,10 +232,13 @@ int snd_init()
PaStreamParameters params;
PaError err = Pa_Initialize();
mixing_rate = config.snd_rate;
sound_lock = lock_create();
if(!config.snd_enable)
return 0;
mixing_rate = config.snd_rate;
params.device = Pa_GetDefaultOutputDevice();
if(params.device < 0)
return 1;
@ -243,7 +247,6 @@ int snd_init()
params.suggestedLatency = Pa_GetDeviceInfo(params.device)->defaultLowOutputLatency;
params.hostApiSpecificStreamInfo = 0x0;
err = Pa_OpenStream(
&stream, /* passes back stream pointer */
0, /* no input channels */
@ -255,6 +258,7 @@ int snd_init()
0x0); /* pass our data through to callback */
err = Pa_StartStream(stream);
sound_enabled = 1;
return 0;
}
@ -339,6 +343,10 @@ int snd_load_wv(const char *filename)
if(config.stress)
return -1;
/* no need to load sound when we are running with no sound */
if(!sound_enabled)
return 1;
file = fopen(filename, "rb"); /* TODO: use system.h stuff for this */
if(!file)
{

View file

@ -16,10 +16,10 @@ struct pretty_font
extern struct pretty_font *current_font;
static void *hot_item = 0;
static void *active_item = 0;
static void *last_active_item = 0;
static void *becomming_hot_item = 0;
static const void *hot_item = 0;
static const void *active_item = 0;
static const void *last_active_item = 0;
static const void *becomming_hot_item = 0;
static float mouse_x, mouse_y; /* in gui space */
static float mouse_wx, mouse_wy; /* in world space */
static unsigned mouse_buttons = 0;
@ -30,12 +30,12 @@ float ui_mouse_world_x() { return mouse_wx; }
float ui_mouse_world_y() { return mouse_wy; }
int ui_mouse_button(int index) { return (mouse_buttons>>index)&1; }
void ui_set_hot_item(void *id) { becomming_hot_item = id; }
void ui_set_active_item(void *id) { active_item = id; if (id) last_active_item = id; }
void ui_set_hot_item(const void *id) { becomming_hot_item = id; }
void ui_set_active_item(const void *id) { active_item = id; if (id) last_active_item = id; }
void ui_clear_last_active_item() { last_active_item = 0; }
void *ui_hot_item() { return hot_item; }
void *ui_active_item() { return active_item; }
void *ui_last_active_item() { return last_active_item; }
const void *ui_hot_item() { return hot_item; }
const void *ui_active_item() { return active_item; }
const void *ui_last_active_item() { return last_active_item; }
int ui_update(float mx, float my, float mwx, float mwy, int buttons)
{
@ -80,7 +80,7 @@ void ui_do_label(float x, float y, const char *text, float size)
gfx_pretty_text(x, y, size, text, -1);
}
int ui_do_button(void *id, const char *text, int checked, float x, float y, float w, float h, draw_button_callback draw_func, void *extra)
int ui_do_button(const void *id, const char *text, int checked, float x, float y, float w, float h, draw_button_callback draw_func, void *extra)
{
/* logic */
int r = 0;

View file

@ -13,20 +13,20 @@ float ui_mouse_world_x();
float ui_mouse_world_y();
int ui_mouse_button(int index);
void ui_set_hot_item(void *id);
void ui_set_active_item(void *id);
void ui_set_hot_item(const void *id);
void ui_set_active_item(const void *id);
void ui_clear_last_active_item();
void *ui_hot_item();
void *ui_active_item();
void *ui_last_active_item();
const void *ui_hot_item();
const void *ui_active_item();
const void *ui_last_active_item();
int ui_mouse_inside(float x, float y, float w, float h);
typedef void (*draw_button_callback)(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra);
typedef void (*draw_button_callback)(const void *id, const char *text, int checked, float x, float y, float w, float h, void *extra);
void ui_do_image(int texture, float x, float y, float w, float h);
void ui_do_label(float x, float y, const char *text, float size);
int ui_do_button(void *id, const char *text, int checked, float x, float y, float w, float h, draw_button_callback draw_func, void *extra);
int ui_do_button(const void *id, const char *text, int checked, float x, float y, float w, float h, draw_button_callback draw_func, void *extra);
#ifdef __cplusplus
}

View file

@ -23,6 +23,7 @@ MACRO_CONFIG_INT(b_sort, 0, 0, 0)
MACRO_CONFIG_INT(b_max_requests, 10, 0, 0)
MACRO_CONFIG_INT(snd_rate, 48000, 0, 0)
MACRO_CONFIG_INT(snd_enable, 1, 0, 1)
MACRO_CONFIG_INT(gfx_screen_width, 800, 0, 0)
MACRO_CONFIG_INT(gfx_screen_height, 600, 0, 0)

View file

@ -1236,7 +1236,7 @@ void draw_circle(float x, float y, float r, int segments)
}
}
void draw_round_rect(float x, float y, float w, float h, float r)
void draw_round_rect_ext(float x, float y, float w, float h, float r, int corners)
{
int num = 8;
for(int i = 0; i < num; i+=2)
@ -1251,24 +1251,28 @@ void draw_round_rect(float x, float y, float w, float h, float r)
float sa2 = sinf(a2);
float sa3 = sinf(a3);
if(corners&1) // TL
gfx_quads_draw_freeform(
x+r, y+r,
x+(1-ca1)*r, y+(1-sa1)*r,
x+(1-ca3)*r, y+(1-sa3)*r,
x+(1-ca2)*r, y+(1-sa2)*r);
if(corners&2) // TR
gfx_quads_draw_freeform(
x+w-r, y+r,
x+w-r+ca1*r, y+(1-sa1)*r,
x+w-r+ca3*r, y+(1-sa3)*r,
x+w-r+ca2*r, y+(1-sa2)*r);
if(corners&4) // BL
gfx_quads_draw_freeform(
x+r, y+h-r,
x+(1-ca1)*r, y+h-r+sa1*r,
x+(1-ca3)*r, y+h-r+sa3*r,
x+(1-ca2)*r, y+h-r+sa2*r);
if(corners&8) // BR
gfx_quads_draw_freeform(
x+w-r, y+h-r,
x+w-r+ca1*r, y+h-r+sa1*r,
@ -1281,8 +1285,19 @@ void draw_round_rect(float x, float y, float w, float h, float r)
gfx_quads_drawTL(x+r, y+h-r, w-r*2, r); // bottom
gfx_quads_drawTL(x, y+r, r, h-r*2); // left
gfx_quads_drawTL(x+w-r, y+r, r, h-r*2); // right
if(!(corners&1)) gfx_quads_drawTL(x, y, r, r); // TL
if(!(corners&2)) gfx_quads_drawTL(x+w, y, -r, r); // TR
if(!(corners&4)) gfx_quads_drawTL(x, y+h, r, -r); // BL
if(!(corners&8)) gfx_quads_drawTL(x+w, y+h, -r, -r); // BR
}
void draw_round_rect(float x, float y, float w, float h, float r)
{
draw_round_rect_ext(x,y,w,h,r,0xf);
}
static void render_player(
const obj_player_character *prev_char,
const obj_player_character *player_char,

View file

@ -195,12 +195,12 @@ void draw_background(float t)
gfx_quads_end();
}
void draw_image_button(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra)
void draw_image_button(const void *id, const char *text, int checked, float x, float y, float w, float h, void *extra)
{
ui_do_image(*(int *)id, x, y, w, h);
}
void draw_single_part_button(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra)
void draw_single_part_button(const void *id, const char *text, int checked, float x, float y, float w, float h, void *extra)
{
gui_tileset_enum tileset;
@ -215,7 +215,7 @@ void draw_single_part_button(void *id, const char *text, int checked, float x, f
draw_part((int)((char*)extra-(char*)0), tileset, x, y, w, h);
}
void draw_menu_button(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra)
void draw_menu_button(const void *id, const char *text, int checked, float x, float y, float w, float h, void *extra)
{
int box_type;
if ((int)((char*)extra-(char*)0))
@ -227,7 +227,7 @@ void draw_menu_button(void *id, const char *text, int checked, float x, float y,
ui_do_label(x + 10, y, text, 28);
}
void draw_teewars_button(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra)
void draw_teewars_button(const void *id, const char *text, int checked, float x, float y, float w, float h, void *extra)
{
const float font_size = h-6.0f;//42.0f;
@ -1758,6 +1758,8 @@ void modmenu_shutdown()
{
}
extern int menu2_render();
extern "C" int modmenu_render(int ingame) // TODO: nastyness
{
static int mouse_x = 0;
@ -1788,7 +1790,9 @@ extern "C" int modmenu_render(int ingame) // TODO: nastyness
}
//int r = menu_render(server_address, str, max_len);
int r = menu_render(ingame);
//int r = menu2_render(ingame);
(void)menu_render;
int r = menu2_render();
gfx_texture_set(data->images[IMAGE_CURSOR].id);
gfx_quads_begin();

1109
src/game/client/menu2.cpp Normal file

File diff suppressed because it is too large Load diff

View file

@ -44,6 +44,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_STR(sv_msg, 512, "")