2007-05-22 15:03:32 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
2007-05-28 13:49:44 +00:00
|
|
|
#include <string.h>
|
2007-06-10 17:25:08 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <baselib/system.h>
|
|
|
|
#include <baselib/stream/file.h>
|
|
|
|
#include <baselib/stream/line.h>
|
|
|
|
|
2007-05-28 13:49:44 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
#include <baselib/system.h>
|
2007-06-10 15:19:04 +00:00
|
|
|
#include <baselib/input.h>
|
2007-05-22 15:03:32 +00:00
|
|
|
#include <baselib/network.h>
|
2007-07-21 18:07:27 +00:00
|
|
|
#include <baselib/math.h>
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-05-24 20:54:08 +00:00
|
|
|
#include <engine/interface.h>
|
|
|
|
#include <engine/versions.h>
|
|
|
|
#include "../mapres.h"
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-05-24 20:54:08 +00:00
|
|
|
#include <engine/client/ui.h>
|
|
|
|
#include "mapres_image.h"
|
|
|
|
#include "mapres_tilemap.h"
|
2007-06-01 11:17:10 +00:00
|
|
|
#include <engine/config.h>
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-07-14 23:08:17 +00:00
|
|
|
#include "data.h"
|
2007-07-21 18:07:27 +00:00
|
|
|
#include <mastersrv/mastersrv.h>
|
2007-07-14 23:08:17 +00:00
|
|
|
|
2007-07-16 18:40:14 +00:00
|
|
|
extern data_container *data;
|
2007-07-16 16:48:16 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
using namespace baselib;
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
MENU
|
|
|
|
*********************************************************/
|
|
|
|
|
2007-05-27 18:14:24 +00:00
|
|
|
enum gui_tileset_enum
|
|
|
|
{
|
|
|
|
tileset_regular,
|
|
|
|
tileset_hot,
|
|
|
|
tileset_active,
|
|
|
|
tileset_inactive
|
|
|
|
};
|
|
|
|
|
|
|
|
int gui_tileset_texture;
|
2007-07-21 18:18:06 +00:00
|
|
|
int cursor_texture;
|
2007-07-21 21:08:28 +00:00
|
|
|
int cloud1_texture, cloud2_texture, cloud3_texture;
|
2007-07-22 13:19:18 +00:00
|
|
|
int menu_background_texture;
|
|
|
|
int butterflies_texture;
|
2007-05-27 18:14:24 +00:00
|
|
|
|
2007-07-16 16:48:16 +00:00
|
|
|
void draw_area(gui_tileset_enum tileset, int areax, int areay, int areaw, int areah, float x, float y, float w, float h)
|
2007-05-27 18:14:24 +00:00
|
|
|
{
|
|
|
|
const float tex_w = 512.0, tex_h = 512.0;
|
|
|
|
|
|
|
|
switch (tileset)
|
|
|
|
{
|
|
|
|
case tileset_regular:
|
2007-07-16 16:48:16 +00:00
|
|
|
break;
|
2007-05-27 18:14:24 +00:00
|
|
|
case tileset_hot:
|
2007-07-16 16:48:16 +00:00
|
|
|
areax += 192; areay += 192; break;
|
2007-05-27 18:14:24 +00:00
|
|
|
case tileset_active:
|
2007-07-16 16:48:16 +00:00
|
|
|
areay += 192; break;
|
2007-05-27 18:14:24 +00:00
|
|
|
case tileset_inactive:
|
2007-07-16 16:48:16 +00:00
|
|
|
areax += 192; break;
|
2007-05-27 18:14:24 +00:00
|
|
|
default:
|
|
|
|
dbg_msg("menu", "invalid tileset given to draw_part");
|
|
|
|
}
|
2007-07-16 16:48:16 +00:00
|
|
|
|
|
|
|
float ts_x = areax / tex_w;
|
|
|
|
float ts_y = areay / tex_h;
|
|
|
|
float te_x = (areax + areaw) / tex_w;
|
|
|
|
float te_y = (areay + areah) / tex_h;
|
|
|
|
|
2007-05-27 18:14:24 +00:00
|
|
|
gfx_blend_normal();
|
|
|
|
gfx_texture_set(gui_tileset_texture);
|
|
|
|
gfx_quads_begin();
|
|
|
|
gfx_quads_setcolor(1,1,1,1);
|
|
|
|
gfx_quads_setsubset(
|
2007-07-16 16:48:16 +00:00
|
|
|
ts_x, // startx
|
|
|
|
ts_y, // starty
|
|
|
|
te_x, // endx
|
|
|
|
te_y); // endy
|
2007-05-27 18:14:24 +00:00
|
|
|
gfx_quads_drawTL(x,y,w,h);
|
|
|
|
gfx_quads_end();
|
2007-05-28 13:49:44 +00:00
|
|
|
}
|
|
|
|
|
2007-07-16 16:48:16 +00:00
|
|
|
void draw_part(int part_type, gui_tileset_enum tileset, float x, float y, float w, float h)
|
2007-05-28 13:49:44 +00:00
|
|
|
{
|
2007-07-16 16:48:16 +00:00
|
|
|
gui_box part = data->gui.misc[part_type];
|
|
|
|
|
|
|
|
draw_area(tileset, part.x, part.y, part.w, part.h, x, y, w, h);
|
|
|
|
|
|
|
|
//draw_part(parts[part], tileset, x, y, w, h);
|
2007-05-27 18:14:24 +00:00
|
|
|
}
|
|
|
|
|
2007-07-16 16:48:16 +00:00
|
|
|
void draw_part(int part_type, gui_tileset_enum tileset, float x, float y)
|
2007-05-27 18:14:24 +00:00
|
|
|
{
|
2007-07-16 16:48:16 +00:00
|
|
|
gui_box part = data->gui.misc[part_type];
|
|
|
|
|
|
|
|
draw_part(part_type, tileset, x, y, part.w, part.h);
|
2007-05-27 18:14:24 +00:00
|
|
|
}
|
|
|
|
|
2007-07-16 16:48:16 +00:00
|
|
|
void draw_box(int box_type, gui_tileset_enum tileset, float x, float y, float w, float h)
|
|
|
|
{
|
|
|
|
gui_compositebox box = data->gui.boxes[box_type];
|
|
|
|
|
|
|
|
/* A composite box consists of 9 parts. To get the coordinates for all corners, we need A, B, C and D:
|
|
|
|
* A----+----+----+
|
|
|
|
* | tl | tm | tr |
|
|
|
|
* +----B----+----+
|
|
|
|
* | ml | mm | mr |
|
|
|
|
* +----+----C----+
|
|
|
|
* | bl | bm | br |
|
|
|
|
* +----+----+----D
|
|
|
|
*/
|
|
|
|
|
|
|
|
int ax = box.rect.x;
|
|
|
|
int ay = box.rect.y;
|
|
|
|
|
|
|
|
int bx = box.center.x;
|
|
|
|
int by = box.center.y;
|
|
|
|
|
|
|
|
int cx = box.center.x + box.center.w;
|
|
|
|
int cy = box.center.y + box.center.h;
|
|
|
|
|
|
|
|
int dx = box.rect.x + box.rect.w;
|
|
|
|
int dy = box.rect.y + box.rect.h;
|
|
|
|
|
|
|
|
draw_area(tileset, ax, ay, bx-ax, by-ay, x, y, bx-ax, by-ay);
|
|
|
|
draw_area(tileset, bx, ay, cx-bx, by-ay, x+bx-ax, y, w-(bx-ax)-(dx-cx), by-ay);
|
|
|
|
draw_area(tileset, cx, ay, dx-cx, by-ay, x+w-(dx-cx), y, dx-cx, by-ay);
|
2007-05-28 13:49:44 +00:00
|
|
|
|
2007-07-16 16:48:16 +00:00
|
|
|
draw_area(tileset, ax, by, bx-ax, cy-by, x, y+(by-ay), bx-ax, h-(by-ay)-(dy-cy));
|
|
|
|
draw_area(tileset, bx, by, cx-bx, cy-by, x+bx-ax, y+(by-ay), w-(bx-ax)-(dx-cx), h-(by-ay)-(dy-cy));
|
|
|
|
draw_area(tileset, cx, by, dx-cx, cy-by, x+w-(dx-cx), y+(by-ay), dx-cx, h-(by-ay)-(dy-cy));
|
2007-05-28 13:49:44 +00:00
|
|
|
|
2007-07-16 16:48:16 +00:00
|
|
|
draw_area(tileset, ax, cy, bx-ax, dy-cy, x, y+h-(dy-cy), bx-ax, dy-cy);
|
|
|
|
draw_area(tileset, bx, cy, cx-bx, dy-cy, x+bx-ax, y+h-(dy-cy), w-(bx-ax)-(dx-cx), dy-cy);
|
|
|
|
draw_area(tileset, cx, cy, dx-cx, dy-cy, x+w-(dx-cx), y+h-(dy-cy), dx-cx, dy-cy);
|
2007-05-28 13:49:44 +00:00
|
|
|
}
|
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
struct pretty_font
|
|
|
|
{
|
2007-06-10 20:00:58 +00:00
|
|
|
float m_CharStartTable[256];
|
|
|
|
float m_CharEndTable[256];
|
2007-05-22 15:03:32 +00:00
|
|
|
int font_texture;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern pretty_font *current_font;
|
|
|
|
float gfx_pretty_text_width(float size, const char *text);
|
|
|
|
|
2007-07-21 12:57:36 +00:00
|
|
|
void render_sun(float x, float y);
|
|
|
|
|
|
|
|
void draw_background(float t)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-21 12:57:36 +00:00
|
|
|
// background color
|
|
|
|
gfx_clear(0.65f,0.78f,0.9f);
|
|
|
|
|
|
|
|
gfx_blend_normal();
|
2007-07-22 13:19:18 +00:00
|
|
|
|
2007-07-21 12:57:36 +00:00
|
|
|
render_sun(170, 170);
|
|
|
|
|
2007-07-21 21:08:28 +00:00
|
|
|
gfx_texture_set(cloud1_texture);
|
|
|
|
gfx_quads_begin();
|
|
|
|
gfx_quads_setcolor(1,1,1,1);
|
|
|
|
gfx_quads_setsubset(
|
|
|
|
0.0f, // startx
|
|
|
|
0.0f, // starty
|
|
|
|
1.0f, // endx
|
|
|
|
1.0f); // endy
|
2007-07-22 13:19:18 +00:00
|
|
|
gfx_quads_drawTL(3500 - fmod(t * 20 + 2000, 4524), 0, 512, 512);
|
2007-07-21 21:08:28 +00:00
|
|
|
gfx_quads_end();
|
|
|
|
|
|
|
|
gfx_texture_set(cloud2_texture);
|
|
|
|
gfx_quads_begin();
|
|
|
|
gfx_quads_setcolor(1,1,1,1);
|
|
|
|
gfx_quads_setsubset(
|
|
|
|
0.0f, // startx
|
|
|
|
0.0f, // starty
|
|
|
|
1.0f, // endx
|
|
|
|
1.0f); // endy
|
2007-07-22 13:19:18 +00:00
|
|
|
gfx_quads_drawTL(3000 - fmod(t * 50 + 1000, 4024), 150, 512, 512);
|
2007-07-21 21:08:28 +00:00
|
|
|
gfx_quads_end();
|
|
|
|
|
|
|
|
gfx_texture_set(cloud3_texture);
|
|
|
|
gfx_quads_begin();
|
|
|
|
gfx_quads_setcolor(1,1,1,1);
|
|
|
|
gfx_quads_setsubset(
|
|
|
|
0.0f, // startx
|
|
|
|
0.0f, // starty
|
|
|
|
1.0f, // endx
|
|
|
|
1.0f); // endy
|
2007-07-22 13:19:18 +00:00
|
|
|
gfx_quads_drawTL(4000 - fmod(t * 60, 4512), 300, 256, 256);
|
2007-07-21 21:08:28 +00:00
|
|
|
gfx_quads_end();
|
|
|
|
|
2007-07-22 13:19:18 +00:00
|
|
|
gfx_texture_set(menu_background_texture);
|
|
|
|
gfx_quads_begin();
|
|
|
|
gfx_quads_setcolor(1,1,1,1);
|
|
|
|
gfx_quads_setsubset(
|
|
|
|
0.0f, // startx
|
|
|
|
0.0f, // starty
|
|
|
|
1.0f, // endx
|
|
|
|
1.0f); // endy
|
|
|
|
gfx_quads_drawTL(0, -400, 1600, 1600);
|
|
|
|
gfx_quads_end();
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-07-22 13:19:18 +00:00
|
|
|
int frame = int(t * 10) % 3;
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-07-22 13:19:18 +00:00
|
|
|
//float x_path = -t
|
|
|
|
|
|
|
|
float x_nudge = 3*cos(t*10);
|
|
|
|
float y_nudge = 8*sin(t*3);
|
|
|
|
|
|
|
|
x_nudge += 150 * cos(t/3);
|
|
|
|
y_nudge += 30 * sin(t/3);
|
|
|
|
|
|
|
|
float angl = t/3;
|
|
|
|
angl = fmod(angl, 2*pi);
|
|
|
|
|
|
|
|
bool flip = angl > pi;
|
|
|
|
|
|
|
|
gfx_texture_set(butterflies_texture);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_begin();
|
2007-07-22 13:19:18 +00:00
|
|
|
gfx_quads_setcolor(1, 1, 1, 1);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_setsubset(
|
2007-07-22 13:19:18 +00:00
|
|
|
flip ? (frame + 1) * 0.25f : frame * 0.25f, // startx
|
|
|
|
0.0f, // starty
|
|
|
|
flip ? frame * 0.25f : (frame + 1) * 0.25f, // endx
|
|
|
|
0.5f); // endy
|
|
|
|
gfx_quads_drawTL(1250 + x_nudge, 480 + y_nudge, 64, 64);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_end();
|
|
|
|
}
|
|
|
|
|
2007-06-10 21:35:59 +00:00
|
|
|
static int background_texture;
|
|
|
|
static int teewars_banner_texture;
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-06-10 21:35:59 +00:00
|
|
|
static int music_menu;
|
|
|
|
static int music_menu_id = -1;
|
2007-05-22 15:03:32 +00:00
|
|
|
|
|
|
|
void draw_image_button(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);
|
|
|
|
}
|
|
|
|
|
2007-05-27 18:14:24 +00:00
|
|
|
void draw_single_part_button(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra)
|
|
|
|
{
|
|
|
|
gui_tileset_enum tileset;
|
|
|
|
|
|
|
|
if (ui_active_item() == id && ui_hot_item() == id)
|
|
|
|
tileset = tileset_active;
|
|
|
|
else if (ui_hot_item() == id)
|
|
|
|
tileset = tileset_hot;
|
|
|
|
else
|
|
|
|
tileset = tileset_regular;
|
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
|
2007-07-16 16:48:16 +00:00
|
|
|
draw_part((int)((char*)extra-(char*)0), tileset, x, y, w, h);
|
2007-05-27 18:14:24 +00:00
|
|
|
}
|
|
|
|
|
2007-06-01 02:21:46 +00:00
|
|
|
void draw_menu_button(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra)
|
|
|
|
{
|
2007-07-16 16:48:16 +00:00
|
|
|
int box_type;
|
2007-07-13 13:40:04 +00:00
|
|
|
if ((int)((char*)extra-(char*)0))
|
2007-07-16 16:48:16 +00:00
|
|
|
box_type = GUI_BOX_SCREEN_INFO;
|
2007-06-01 02:21:46 +00:00
|
|
|
else
|
2007-07-16 16:48:16 +00:00
|
|
|
box_type = GUI_BOX_SCREEN_LIST;
|
|
|
|
draw_box(box_type, tileset_regular, x, y, w, h);
|
2007-06-01 02:21:46 +00:00
|
|
|
|
|
|
|
ui_do_label(x + 10, y, text, 28);
|
|
|
|
}
|
|
|
|
|
2007-05-27 18:14:24 +00:00
|
|
|
void draw_teewars_button(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra)
|
|
|
|
{
|
2007-07-22 13:43:31 +00:00
|
|
|
const float font_size = 42.0f;
|
2007-07-21 18:18:06 +00:00
|
|
|
|
|
|
|
float text_width = gfx_pretty_text_width(font_size, text);
|
2007-05-27 18:14:24 +00:00
|
|
|
gui_tileset_enum tileset;
|
|
|
|
|
2007-07-20 22:19:40 +00:00
|
|
|
if (ui_active_item() == id)
|
2007-07-21 12:57:36 +00:00
|
|
|
{
|
|
|
|
int inside = ui_mouse_inside(x, y, w, h);
|
|
|
|
tileset = inside ? tileset_active : tileset_hot;
|
|
|
|
}
|
2007-05-27 18:14:24 +00:00
|
|
|
else if (ui_hot_item() == id)
|
|
|
|
tileset = tileset_hot;
|
|
|
|
else
|
|
|
|
tileset = tileset_regular;
|
|
|
|
|
2007-07-13 13:40:04 +00:00
|
|
|
if ((int)((char*)extra-(char*)0) == 1)
|
2007-05-28 13:49:44 +00:00
|
|
|
tileset = tileset_inactive;
|
2007-05-27 18:14:24 +00:00
|
|
|
|
2007-07-16 16:48:16 +00:00
|
|
|
draw_box(GUI_BOX_BUTTON, tileset, x, y, w, h);
|
2007-05-27 18:14:24 +00:00
|
|
|
|
2007-07-22 13:43:31 +00:00
|
|
|
ui_do_label(x + w/2 - text_width/2, y + 2, text, font_size);
|
2007-05-27 18:14:24 +00:00
|
|
|
}
|
|
|
|
|
2007-07-21 18:07:27 +00:00
|
|
|
/*
|
2007-05-22 15:03:32 +00:00
|
|
|
struct server_info
|
|
|
|
{
|
|
|
|
int version;
|
|
|
|
int players;
|
|
|
|
int max_players;
|
|
|
|
netaddr4 address;
|
|
|
|
char name[129];
|
|
|
|
char map[65];
|
2007-07-21 18:07:27 +00:00
|
|
|
};*/
|
2007-05-22 15:03:32 +00:00
|
|
|
|
|
|
|
struct server_list
|
|
|
|
{
|
|
|
|
int active_count, info_count;
|
|
|
|
int scroll_index;
|
|
|
|
int selected_index;
|
|
|
|
};
|
|
|
|
|
2007-06-01 02:21:46 +00:00
|
|
|
int ui_do_key_reader(void *id, float x, float y, float w, float h, int key)
|
|
|
|
{
|
|
|
|
// process
|
2007-07-20 22:30:11 +00:00
|
|
|
static bool mouse_released = true;
|
2007-06-01 02:21:46 +00:00
|
|
|
int inside = ui_mouse_inside(x, y, w, h);
|
|
|
|
int new_key = key;
|
2007-07-20 22:30:11 +00:00
|
|
|
|
|
|
|
if(!ui_mouse_button(0))
|
|
|
|
mouse_released = true;
|
2007-06-10 15:19:04 +00:00
|
|
|
|
2007-07-20 22:19:40 +00:00
|
|
|
if(ui_active_item() == id)
|
2007-06-01 02:21:46 +00:00
|
|
|
{
|
2007-07-20 22:19:40 +00:00
|
|
|
int k = input::last_key();
|
|
|
|
if (k)
|
2007-06-10 15:19:04 +00:00
|
|
|
{
|
2007-07-20 22:19:40 +00:00
|
|
|
new_key = k;
|
|
|
|
ui_set_active_item(0);
|
2007-07-20 22:30:11 +00:00
|
|
|
mouse_released = false;
|
2007-06-10 15:19:04 +00:00
|
|
|
}
|
2007-06-01 02:21:46 +00:00
|
|
|
}
|
2007-07-20 22:19:40 +00:00
|
|
|
else if(ui_hot_item() == id)
|
2007-06-01 02:21:46 +00:00
|
|
|
{
|
2007-07-20 22:30:11 +00:00
|
|
|
if(ui_mouse_button(0) && mouse_released)
|
2007-07-20 22:19:40 +00:00
|
|
|
ui_set_active_item(id);
|
2007-06-01 02:21:46 +00:00
|
|
|
}
|
2007-07-20 22:19:40 +00:00
|
|
|
|
|
|
|
if(inside)
|
|
|
|
ui_set_hot_item(id);
|
|
|
|
|
2007-06-01 02:21:46 +00:00
|
|
|
// draw
|
2007-07-22 13:19:18 +00:00
|
|
|
int box_type;
|
|
|
|
if (ui_active_item() == id || ui_hot_item() == id)
|
|
|
|
box_type = GUI_BOX_SCREEN_INFO;
|
|
|
|
else
|
|
|
|
box_type = GUI_BOX_SCREEN_TEXTBOX;
|
|
|
|
draw_box(box_type, tileset_regular, x, y, w, h);
|
2007-06-01 02:21:46 +00:00
|
|
|
|
2007-06-10 15:19:04 +00:00
|
|
|
const char *str = input::key_name(key);
|
2007-06-01 02:21:46 +00:00
|
|
|
ui_do_label(x + 10, y, str, 36);
|
|
|
|
if (ui_active_item() == id)
|
|
|
|
{
|
|
|
|
float w = gfx_pretty_text_width(36.0f, str);
|
|
|
|
ui_do_label(x + 10 + w, y, "_", 36);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new_key;
|
|
|
|
}
|
|
|
|
|
2007-06-10 15:42:19 +00:00
|
|
|
int ui_do_combo_box(void *id, float x, float y, float w, char *lines, int line_count, int selected_index)
|
2007-06-01 02:21:46 +00:00
|
|
|
{
|
|
|
|
float line_height = 36.0f;
|
|
|
|
|
|
|
|
int inside = (ui_active_item() == id) ? ui_mouse_inside(x, y, w, line_count * line_height) : ui_mouse_inside(x, y, w, line_height);
|
2007-07-13 13:40:04 +00:00
|
|
|
int hover_index = (int)((ui_mouse_y() - y) / line_height);
|
2007-06-01 02:21:46 +00:00
|
|
|
|
2007-07-21 16:33:01 +00:00
|
|
|
if (ui_active_item() == id)
|
|
|
|
{
|
|
|
|
if (!ui_mouse_button(0))
|
|
|
|
{
|
|
|
|
ui_set_active_item(0);
|
|
|
|
|
|
|
|
if (inside)
|
|
|
|
selected_index = hover_index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ui_hot_item() == id)
|
|
|
|
{
|
|
|
|
if (ui_mouse_button(0))
|
|
|
|
ui_set_active_item(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inside)
|
|
|
|
{
|
|
|
|
ui_set_hot_item(id);
|
|
|
|
}
|
|
|
|
|
2007-06-01 02:21:46 +00:00
|
|
|
if (ui_active_item() == id)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < line_count; i++)
|
|
|
|
{
|
2007-07-16 16:48:16 +00:00
|
|
|
int box_type;
|
2007-06-01 02:21:46 +00:00
|
|
|
if (inside && hover_index == i)
|
2007-07-16 16:48:16 +00:00
|
|
|
box_type = GUI_BOX_SCREEN_INFO;
|
2007-06-01 02:21:46 +00:00
|
|
|
else
|
2007-07-16 16:48:16 +00:00
|
|
|
box_type = GUI_BOX_SCREEN_LIST;
|
2007-06-01 02:21:46 +00:00
|
|
|
|
2007-07-16 16:48:16 +00:00
|
|
|
draw_box(box_type, tileset_regular, x, y + i * line_height, w, line_height);
|
2007-06-10 15:42:19 +00:00
|
|
|
ui_do_label(x + 10 + 10, y + i * line_height, lines + 128 * i, 36);
|
2007-06-01 02:21:46 +00:00
|
|
|
if (selected_index == i)
|
|
|
|
ui_do_label(x + 10, y + i * line_height, "-", 36);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-07-22 13:19:18 +00:00
|
|
|
int box_type;
|
|
|
|
if (ui_active_item() == id || ui_hot_item() == id)
|
|
|
|
box_type = GUI_BOX_SCREEN_INFO;
|
|
|
|
else
|
|
|
|
box_type = GUI_BOX_SCREEN_TEXTBOX;
|
|
|
|
draw_box(box_type, tileset_regular, x, y, w, line_height);
|
2007-06-10 15:42:19 +00:00
|
|
|
ui_do_label(x + 10, y, lines + 128 * selected_index, 36);
|
2007-06-01 02:21:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return selected_index;
|
|
|
|
}
|
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
int ui_do_edit_box(void *id, float x, float y, float w, float h, char *str, int str_size)
|
|
|
|
{
|
|
|
|
int inside = ui_mouse_inside(x, y, w, h);
|
|
|
|
int r = 0;
|
|
|
|
|
2007-07-20 22:30:11 +00:00
|
|
|
if(ui_last_active_item() == id)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-06-10 15:19:04 +00:00
|
|
|
int c = input::last_char();
|
|
|
|
int k = input::last_key();
|
2007-05-22 15:03:32 +00:00
|
|
|
int len = strlen(str);
|
2007-06-11 19:59:29 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
if (c >= 32 && c < 128)
|
|
|
|
{
|
|
|
|
if (len < str_size - 1)
|
|
|
|
{
|
|
|
|
str[len] = c;
|
|
|
|
str[len+1] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-10 15:19:04 +00:00
|
|
|
if (k == input::backspace)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
|
|
|
if (len > 0)
|
|
|
|
str[len-1] = 0;
|
|
|
|
}
|
2007-07-21 16:33:01 +00:00
|
|
|
else if (k == input::enter)
|
|
|
|
ui_clear_last_active_item();
|
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
r = 1;
|
|
|
|
}
|
2007-07-21 18:18:06 +00:00
|
|
|
|
|
|
|
int box_type;
|
|
|
|
if (ui_active_item() == id || ui_hot_item() == id || ui_last_active_item() == id)
|
|
|
|
box_type = GUI_BOX_SCREEN_INFO;
|
|
|
|
else
|
|
|
|
box_type = GUI_BOX_SCREEN_TEXTBOX;
|
2007-07-20 22:30:11 +00:00
|
|
|
|
|
|
|
if(ui_active_item() == id)
|
|
|
|
{
|
|
|
|
if(!ui_mouse_button(0))
|
|
|
|
ui_set_active_item(0);
|
|
|
|
}
|
2007-07-20 22:19:40 +00:00
|
|
|
else if(ui_hot_item() == id)
|
|
|
|
{
|
|
|
|
if(ui_mouse_button(0))
|
|
|
|
ui_set_active_item(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(inside)
|
2007-07-20 22:30:11 +00:00
|
|
|
ui_set_hot_item(id);
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-07-21 18:18:06 +00:00
|
|
|
|
|
|
|
draw_box(box_type, tileset_regular, x, y, w, h);
|
2007-05-28 13:49:44 +00:00
|
|
|
|
2007-06-01 02:21:46 +00:00
|
|
|
ui_do_label(x + 10, y, str, 36);
|
|
|
|
|
2007-07-20 22:30:11 +00:00
|
|
|
if (ui_last_active_item() == id)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-05-28 13:49:44 +00:00
|
|
|
float w = gfx_pretty_text_width(36.0f, str);
|
2007-06-01 02:21:46 +00:00
|
|
|
ui_do_label(x + 10 + w, y, "_", 36);
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-07-21 16:33:01 +00:00
|
|
|
int ui_do_check_box(void *id, float x, float y, float w, float h, int value)
|
|
|
|
{
|
|
|
|
int inside = ui_mouse_inside(x, y, w, h);
|
|
|
|
int r = value;
|
|
|
|
|
|
|
|
if(ui_active_item() == id)
|
|
|
|
{
|
|
|
|
if(!ui_mouse_button(0))
|
|
|
|
{
|
|
|
|
ui_set_active_item(0);
|
|
|
|
r = r ? 0 : 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ui_hot_item() == id)
|
|
|
|
{
|
|
|
|
if(ui_mouse_button(0))
|
|
|
|
ui_set_active_item(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(inside)
|
|
|
|
ui_set_hot_item(id);
|
|
|
|
|
|
|
|
// render
|
|
|
|
gui_tileset_enum tileset;
|
|
|
|
int part_type;
|
|
|
|
if (ui_active_item() == id)
|
|
|
|
tileset = tileset_active;
|
|
|
|
else if (ui_hot_item() == id)
|
|
|
|
tileset = tileset_hot;
|
|
|
|
else
|
|
|
|
tileset = tileset_regular;
|
|
|
|
|
|
|
|
part_type = r ? GUI_MISC_RADIO_CHECKED : GUI_MISC_RADIO_UNCHECKED;
|
|
|
|
|
|
|
|
draw_part(part_type, tileset, x, y, w, h);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-07-21 17:43:00 +00:00
|
|
|
int do_scroll_bar_horiz(void *id, float x, float y, float width, int steps, int last_index)
|
|
|
|
{
|
|
|
|
int r = last_index;
|
|
|
|
|
|
|
|
static int up_button;
|
|
|
|
static int down_button;
|
|
|
|
|
|
|
|
if (ui_do_button(&up_button, "", 0, x, y + 8, 16, 16, draw_single_part_button, (void *)GUI_MISC_SLIDER_BIG_ARROW_LEFT))
|
|
|
|
{
|
|
|
|
if (r > 0)
|
|
|
|
--r;
|
|
|
|
}
|
|
|
|
if (ui_do_button(&down_button, "", 0, x + width - 16, y + 8, 16, 16, draw_single_part_button, (void *)GUI_MISC_SLIDER_BIG_ARROW_RIGHT))
|
|
|
|
{
|
|
|
|
if (r < steps)
|
|
|
|
++r;
|
|
|
|
}
|
|
|
|
if (steps > 0) // only if there's actually stuff to scroll through
|
|
|
|
{
|
|
|
|
int inside = ui_mouse_inside(x + 16, y, width - 32, 32);
|
|
|
|
if (inside && (!ui_active_item() || ui_active_item() == id))
|
|
|
|
ui_set_hot_item(id);
|
|
|
|
|
|
|
|
if(ui_active_item() == id)
|
|
|
|
{
|
|
|
|
if (ui_mouse_button(0))
|
|
|
|
{
|
|
|
|
float pos = ui_mouse_x() - x - 16;
|
|
|
|
float perc = pos / (width - 32);
|
|
|
|
|
|
|
|
r = (int)((steps + 1) * perc);
|
|
|
|
if (r < 0)
|
|
|
|
r = 0;
|
|
|
|
else if (r > steps)
|
|
|
|
r = steps;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ui_set_active_item(0);
|
|
|
|
}
|
|
|
|
else if (ui_hot_item() == id && ui_mouse_button(0))
|
|
|
|
ui_set_active_item(id);
|
|
|
|
else if (inside && (!ui_active_item() || ui_active_item() == id))
|
|
|
|
ui_set_hot_item(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
draw_part(GUI_MISC_SLIDER_BIG_HORIZ_BEGIN, tileset_regular, x + 16, y + 8, 16, 16);
|
|
|
|
draw_part(GUI_MISC_SLIDER_BIG_HORIZ_MID, tileset_regular, x + 32, y + 8, width - 32 - 32, 16);
|
|
|
|
draw_part(GUI_MISC_SLIDER_BIG_HORIZ_END, tileset_regular, x + width - 32, y + 8, 16, 16);
|
|
|
|
|
2007-07-21 21:11:54 +00:00
|
|
|
draw_part(GUI_MISC_SLIDER_BIG_HANDLE_HORIZ, tileset_regular, x + 16 + r * ((width - 64) / steps), y + 8, 32, 16);
|
2007-07-21 17:43:00 +00:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
int do_scroll_bar_vert(void *id, float x, float y, float height, int steps, int last_index)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
|
|
|
int r = last_index;
|
|
|
|
|
2007-05-28 13:49:44 +00:00
|
|
|
static int up_button;
|
|
|
|
static int down_button;
|
|
|
|
|
2007-07-16 16:48:16 +00:00
|
|
|
if (ui_do_button(&up_button, "", 0, x + 8, y, 16, 16, draw_single_part_button, (void *)GUI_MISC_SLIDER_BIG_ARROW_UP))
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
|
|
|
if (r > 0)
|
|
|
|
--r;
|
|
|
|
}
|
2007-07-16 16:48:16 +00:00
|
|
|
if (ui_do_button(&down_button, "", 0, x + 8, y + height - 16, 16, 16, draw_single_part_button, (void *)GUI_MISC_SLIDER_BIG_ARROW_DOWN))
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
|
|
|
if (r < steps)
|
|
|
|
++r;
|
|
|
|
}
|
2007-06-01 02:21:46 +00:00
|
|
|
if (steps > 0) // only if there's actually stuff to scroll through
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-05-28 13:49:44 +00:00
|
|
|
int inside = ui_mouse_inside(x, y + 16, 16, height - 32);
|
2007-05-22 15:03:32 +00:00
|
|
|
if (inside && (!ui_active_item() || ui_active_item() == id))
|
|
|
|
ui_set_hot_item(id);
|
|
|
|
|
|
|
|
if(ui_active_item() == id)
|
|
|
|
{
|
|
|
|
if (ui_mouse_button(0))
|
|
|
|
{
|
2007-07-21 17:43:00 +00:00
|
|
|
float pos = ui_mouse_y() - y - 32;
|
2007-05-28 13:49:44 +00:00
|
|
|
float perc = pos / (height - 32);
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-05-27 00:47:07 +00:00
|
|
|
r = (int)((steps + 1) * perc);
|
2007-05-22 15:03:32 +00:00
|
|
|
if (r < 0)
|
|
|
|
r = 0;
|
|
|
|
else if (r > steps)
|
|
|
|
r = steps;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ui_set_active_item(0);
|
|
|
|
}
|
|
|
|
else if (ui_hot_item() == id && ui_mouse_button(0))
|
|
|
|
ui_set_active_item(id);
|
|
|
|
else if (inside && (!ui_active_item() || ui_active_item() == id))
|
|
|
|
ui_set_hot_item(id);
|
|
|
|
}
|
|
|
|
|
2007-07-16 16:48:16 +00:00
|
|
|
draw_part(GUI_MISC_SLIDER_BIG_VERT_BEGIN, tileset_regular, x + 8, y + 16, 16, 16);
|
|
|
|
draw_part(GUI_MISC_SLIDER_BIG_VERT_MID, tileset_regular, x + 8, y + 32, 16, height - 32 - 32);
|
|
|
|
draw_part(GUI_MISC_SLIDER_BIG_VERT_END, tileset_regular, x + 8, y + height - 32, 16, 16);
|
2007-05-27 18:14:24 +00:00
|
|
|
|
2007-07-21 21:11:54 +00:00
|
|
|
draw_part(GUI_MISC_SLIDER_BIG_HANDLE_VERT, tileset_regular, x + 8, y + 16 + r * ((height - 64) / steps), 16, 32);
|
2007-05-27 18:14:24 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-07-21 18:07:27 +00:00
|
|
|
static int do_server_list(float x, float y, int *scroll_index, int *selected_index, int visible_items)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-05-28 13:49:44 +00:00
|
|
|
const float spacing = 3.f;
|
|
|
|
const float item_height = 28;
|
|
|
|
const float item_width = 728;
|
|
|
|
const float real_width = item_width + 20;
|
2007-05-22 15:03:32 +00:00
|
|
|
const float real_height = item_height * visible_items + spacing * (visible_items - 1);
|
|
|
|
|
2007-07-21 18:07:27 +00:00
|
|
|
server_info *servers;
|
|
|
|
int num_servers = client_serverbrowse_getlist(&servers);
|
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
int r = -1;
|
|
|
|
|
|
|
|
for (int i = 0; i < visible_items; i++)
|
|
|
|
{
|
2007-07-21 18:07:27 +00:00
|
|
|
int item_index = i + *scroll_index;
|
|
|
|
if (item_index >= num_servers)
|
|
|
|
;
|
2007-06-01 02:21:46 +00:00
|
|
|
//ui_do_image(empty_item_texture, x, y + i * item_height + i * spacing, item_width, item_height);
|
2007-05-22 15:03:32 +00:00
|
|
|
else
|
|
|
|
{
|
2007-07-21 18:07:27 +00:00
|
|
|
server_info *item = &servers[item_index];
|
2007-05-22 15:03:32 +00:00
|
|
|
|
|
|
|
bool clicked = false;
|
2007-07-21 18:07:27 +00:00
|
|
|
clicked = ui_do_button(item, item->name, 0, x, y + i * item_height + i * spacing, item_width, item_height,
|
|
|
|
draw_menu_button, (*selected_index == item_index) ? (void *)1 : 0);
|
2007-05-22 15:03:32 +00:00
|
|
|
|
|
|
|
char temp[64]; // plenty of extra room so we don't get sad :o
|
2007-07-21 18:07:27 +00:00
|
|
|
sprintf(temp, "%i/%i %3d", item->num_players, item->max_players, item->latency);
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-06-01 02:21:46 +00:00
|
|
|
ui_do_label(x + 600, y + i * item_height + i * spacing, temp, item_height);
|
|
|
|
ui_do_label(x + 360, y + i * item_height + i * spacing, item->map, item_height);
|
2007-05-22 15:03:32 +00:00
|
|
|
|
|
|
|
if (clicked)
|
|
|
|
{
|
|
|
|
r = item_index;
|
2007-07-21 18:07:27 +00:00
|
|
|
*selected_index = item_index;
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-21 18:07:27 +00:00
|
|
|
*scroll_index = do_scroll_bar_vert(scroll_index, x + real_width - 16, y, real_height,
|
|
|
|
min(num_servers - visible_items, 0), *scroll_index);
|
2007-05-22 15:03:32 +00:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-07-21 15:48:35 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SCREEN_MAIN,
|
|
|
|
SCREEN_SETTINGS_GENERAL,
|
|
|
|
SCREEN_SETTINGS_CONTROLS,
|
|
|
|
SCREEN_SETTINGS_VIDEO,
|
|
|
|
SCREEN_SETTINGS_SOUND,
|
|
|
|
SCREEN_KERNING
|
|
|
|
};
|
|
|
|
|
|
|
|
static int screen = SCREEN_MAIN;
|
2007-06-01 11:08:33 +00:00
|
|
|
static configuration config_copy;
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-07-21 15:48:35 +00:00
|
|
|
const float column1_x = 250;
|
2007-07-21 17:43:00 +00:00
|
|
|
const float column2_x = column1_x + 170;
|
2007-07-21 15:48:35 +00:00
|
|
|
const float column3_x = column2_x + 170;
|
|
|
|
const float row1_y = 180;
|
|
|
|
const float row2_y = row1_y + 40;
|
|
|
|
const float row3_y = row2_y + 40;
|
2007-07-21 17:43:00 +00:00
|
|
|
const float row4_y = row3_y + 40;
|
2007-07-21 15:48:35 +00:00
|
|
|
|
2007-07-21 18:07:27 +00:00
|
|
|
static int main_render()
|
2007-06-01 02:21:46 +00:00
|
|
|
{
|
2007-05-22 15:03:32 +00:00
|
|
|
static bool inited = false;
|
|
|
|
|
|
|
|
if (!inited)
|
|
|
|
{
|
|
|
|
inited = true;
|
|
|
|
|
2007-07-21 18:07:27 +00:00
|
|
|
client_serverbrowse_refresh();
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
|
|
|
|
2007-07-21 18:07:27 +00:00
|
|
|
static int scoll_index = 0, selected_index = -1;
|
2007-07-22 13:19:18 +00:00
|
|
|
int last_selected_index = selected_index;
|
2007-07-21 18:07:27 +00:00
|
|
|
do_server_list(20, 160, &scoll_index, &selected_index, 8);
|
2007-07-22 13:19:18 +00:00
|
|
|
|
|
|
|
static char address[32] = "localhost:8303";
|
|
|
|
|
|
|
|
ui_do_edit_box(address, 280, 425, 300, 36, address, sizeof(address));
|
|
|
|
|
|
|
|
if (last_selected_index != selected_index && selected_index != -1)
|
|
|
|
{
|
|
|
|
server_info *servers;
|
|
|
|
client_serverbrowse_getlist(&servers);
|
|
|
|
|
|
|
|
strcpy(address, servers[selected_index].address);
|
|
|
|
}
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-05-28 13:49:44 +00:00
|
|
|
static int refresh_button, join_button, quit_button;
|
|
|
|
|
2007-07-22 13:19:18 +00:00
|
|
|
if (ui_do_button(&refresh_button, "Refresh", 0, 20, 420, 170, 48, draw_teewars_button))
|
2007-07-21 18:07:27 +00:00
|
|
|
client_serverbrowse_refresh();
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-07-22 13:42:28 +00:00
|
|
|
/*if (selected_index == -1)
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-05-28 13:49:44 +00:00
|
|
|
ui_do_button(&join_button, "Join", 0, 620, 420, 128, 48, draw_teewars_button, (void *)1);
|
2007-05-22 15:03:32 +00:00
|
|
|
}
|
2007-07-22 13:42:28 +00:00
|
|
|
else */if (ui_do_button(&join_button, "Join", 0, 620, 420, 128, 48, draw_teewars_button))
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-22 13:19:18 +00:00
|
|
|
client_connect(address);
|
2007-05-22 15:03:32 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-05-28 13:49:44 +00:00
|
|
|
if (ui_do_button(&quit_button, "Quit", 0, 620, 490, 128, 48, draw_teewars_button))
|
2007-05-22 15:03:32 +00:00
|
|
|
return -1;
|
|
|
|
|
2007-06-01 02:21:46 +00:00
|
|
|
static int settings_button;
|
2007-07-22 13:19:18 +00:00
|
|
|
if (ui_do_button(&settings_button, "Settings", 0, 20, 490, 170, 48, draw_teewars_button))
|
2007-06-01 11:08:33 +00:00
|
|
|
{
|
|
|
|
config_copy = config;
|
2007-07-21 15:48:35 +00:00
|
|
|
screen = SCREEN_SETTINGS_GENERAL;
|
2007-06-01 11:08:33 +00:00
|
|
|
}
|
2007-06-01 02:21:46 +00:00
|
|
|
|
2007-07-22 13:42:28 +00:00
|
|
|
/*static int editor_button;
|
|
|
|
if (ui_do_button(&editor_button, "Kerning Editor", 0, 20, 470, 170, 48, draw_teewars_button))
|
|
|
|
screen = SCREEN_KERNING;*/
|
2007-06-10 17:25:08 +00:00
|
|
|
|
2007-06-01 02:21:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-21 15:48:35 +00:00
|
|
|
static int settings_general_render()
|
|
|
|
{
|
2007-06-01 02:21:46 +00:00
|
|
|
// NAME
|
2007-07-21 15:48:35 +00:00
|
|
|
ui_do_label(column1_x, row1_y, "Name:", 36);
|
|
|
|
ui_do_edit_box(config_copy.player_name, column2_x, row1_y, 300, 36, config_copy.player_name, sizeof(config_copy.player_name));
|
2007-06-01 02:21:46 +00:00
|
|
|
|
2007-07-21 15:48:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int settings_controls_render()
|
|
|
|
{
|
2007-06-01 02:21:46 +00:00
|
|
|
// KEYS
|
2007-07-21 18:18:06 +00:00
|
|
|
ui_do_label(column1_x, row1_y + 0, "Move Left:", 36);
|
2007-07-22 13:19:18 +00:00
|
|
|
config_set_key_move_left(&config_copy, ui_do_key_reader(&config_copy.key_move_left, column2_x, row1_y + 0, 150, 36, config_copy.key_move_left));
|
2007-07-21 18:18:06 +00:00
|
|
|
ui_do_label(column1_x, row1_y + 40, "Move Right:", 36);
|
2007-07-22 13:19:18 +00:00
|
|
|
config_set_key_move_right(&config_copy, ui_do_key_reader(&config_copy.key_move_right, column2_x, row1_y + 40, 150, 36, config_copy.key_move_right));
|
2007-07-21 18:18:06 +00:00
|
|
|
ui_do_label(column1_x, row1_y + 80, "Jump:", 36);
|
2007-07-22 13:19:18 +00:00
|
|
|
config_set_key_jump(&config_copy, ui_do_key_reader(&config_copy.key_jump, column2_x, row1_y + 80, 150, 36, config_copy.key_jump));
|
2007-07-21 18:18:06 +00:00
|
|
|
ui_do_label(column1_x, row1_y + 120, "Fire:", 36);
|
2007-07-22 13:19:18 +00:00
|
|
|
config_set_key_fire(&config_copy, ui_do_key_reader(&config_copy.key_fire, column2_x, row1_y + 120, 150, 36, config_copy.key_fire));
|
2007-07-21 18:18:06 +00:00
|
|
|
ui_do_label(column1_x, row1_y + 160, "Hook:", 36);
|
2007-07-22 13:19:18 +00:00
|
|
|
config_set_key_hook(&config_copy, ui_do_key_reader(&config_copy.key_hook, column2_x, row1_y + 160, 150, 36, config_copy.key_hook));
|
2007-07-21 15:48:35 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-06-01 02:21:46 +00:00
|
|
|
|
2007-07-21 15:48:35 +00:00
|
|
|
static int settings_video_render()
|
|
|
|
{
|
2007-07-21 12:57:36 +00:00
|
|
|
static int resolution_count[2] = {0};
|
|
|
|
static int resolutions[2][10][2] = {0};
|
|
|
|
static char resolution_names[2][10][128] = {0};
|
|
|
|
|
|
|
|
static bool inited = false;
|
|
|
|
if (!inited)
|
2007-06-01 11:08:33 +00:00
|
|
|
{
|
2007-07-21 12:57:36 +00:00
|
|
|
const int num_modes = 1024;
|
|
|
|
|
|
|
|
video_mode modes[num_modes];
|
|
|
|
|
|
|
|
int retn = gfx_get_video_modes(modes, num_modes);
|
2007-06-10 15:42:19 +00:00
|
|
|
|
2007-07-21 12:57:36 +00:00
|
|
|
for (int i = 0; i < retn; i++)
|
|
|
|
{
|
|
|
|
video_mode mode = modes[i];
|
|
|
|
int depth = mode.red + mode.green + mode.blue;
|
|
|
|
|
|
|
|
int depth_index;
|
|
|
|
|
|
|
|
if (depth == 15 || depth == 16)
|
|
|
|
depth_index = 0;
|
|
|
|
else if (depth == 24)
|
|
|
|
depth_index = 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dbg_msg("menu", "a resolution with a weird depth was reported: %ix%i (%i/%i/%i)", mode.width, mode.height, mode.red, mode.green, mode.blue);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
int resolution_index = resolution_count[depth_index];
|
|
|
|
resolution_count[depth_index]++;
|
|
|
|
resolutions[depth_index][resolution_index][0] = mode.width;
|
|
|
|
resolutions[depth_index][resolution_index][1] = mode.height;
|
|
|
|
sprintf(resolution_names[depth_index][resolution_index], "%ix%i", mode.width, mode.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
inited = true;
|
|
|
|
}
|
|
|
|
|
2007-07-21 16:33:01 +00:00
|
|
|
int depth_index = (config_copy.color_depth == 16) ? 0 : 1;
|
2007-06-10 15:42:19 +00:00
|
|
|
static int selected_index = -1;
|
|
|
|
if (selected_index == -1)
|
|
|
|
{
|
2007-07-21 12:57:36 +00:00
|
|
|
for (int i = 0; i < resolution_count[depth_index]; i++)
|
2007-06-10 15:42:19 +00:00
|
|
|
{
|
2007-07-22 13:42:28 +00:00
|
|
|
if (config_copy.screen_width == resolutions[depth_index][i][0] && config_copy.screen_height == resolutions[depth_index][i][1])
|
2007-06-10 15:42:19 +00:00
|
|
|
{
|
|
|
|
selected_index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selected_index == -1)
|
|
|
|
selected_index = 1;
|
|
|
|
}
|
|
|
|
|
2007-07-21 15:48:35 +00:00
|
|
|
static char bit_labels[][128] =
|
|
|
|
{
|
|
|
|
"16",
|
2007-07-21 16:33:01 +00:00
|
|
|
"24"
|
2007-07-21 15:48:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// we need to draw these bottom up, to make overlapping work correctly
|
2007-07-22 13:42:28 +00:00
|
|
|
ui_do_label(column1_x, row4_y + 50, "(A restart of the game is required for these settings to take effect.)", 20);
|
|
|
|
|
|
|
|
ui_do_label(column1_x, row4_y, "V-sync:", 36);
|
|
|
|
config_set_vsync(&config_copy, ui_do_check_box(&config_copy.vsync, column2_x, row4_y + 5, 32, 32, config_copy.vsync));
|
2007-07-21 15:48:35 +00:00
|
|
|
|
|
|
|
ui_do_label(column1_x, row3_y, "Fullscreen:", 36);
|
2007-07-21 16:33:01 +00:00
|
|
|
config_set_fullscreen(&config_copy, ui_do_check_box(&config_copy.fullscreen, column2_x, row3_y + 5, 32, 32, config_copy.fullscreen));
|
2007-07-21 15:48:35 +00:00
|
|
|
|
2007-07-21 16:33:01 +00:00
|
|
|
ui_do_label(column1_x, row2_y, "Resolution:", 36);
|
|
|
|
selected_index = ui_do_combo_box(&selected_index, column2_x, row2_y, 170, (char *)resolution_names[depth_index], resolution_count[depth_index], selected_index);
|
|
|
|
|
2007-07-21 17:43:00 +00:00
|
|
|
ui_do_label(column1_x, row1_y, "Color Depth:", 36);
|
2007-07-21 16:33:01 +00:00
|
|
|
depth_index = ui_do_combo_box(&depth_index, column2_x, row1_y, 64, (char *)bit_labels, 2, depth_index);
|
|
|
|
|
2007-06-01 02:21:46 +00:00
|
|
|
|
2007-07-21 16:33:01 +00:00
|
|
|
config_set_color_depth(&config_copy, (depth_index == 0) ? 16 : 24);
|
2007-07-21 12:57:36 +00:00
|
|
|
config_set_screen_width(&config_copy, resolutions[depth_index][selected_index][0]);
|
|
|
|
config_set_screen_height(&config_copy, resolutions[depth_index][selected_index][1]);
|
2007-06-01 11:08:33 +00:00
|
|
|
|
2007-07-21 15:48:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int settings_sound_render()
|
|
|
|
{
|
2007-07-21 17:43:00 +00:00
|
|
|
ui_do_label(column1_x, row1_y, "Volume:", 36);
|
|
|
|
|
|
|
|
config_set_volume(&config_copy, do_scroll_bar_horiz(&config_copy.volume, column2_x, row1_y, 200, 255, config_copy.volume));
|
2007-07-21 18:18:06 +00:00
|
|
|
snd_set_master_volume(config_copy.volume / 255.0f);
|
2007-07-21 17:43:00 +00:00
|
|
|
|
2007-07-21 15:48:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int settings_render()
|
|
|
|
{
|
|
|
|
static int general_button, controls_button, video_button, sound_button;
|
|
|
|
|
|
|
|
if (ui_do_button(&general_button, "General", 0, 30, 200, 170, 48, draw_teewars_button))
|
|
|
|
screen = SCREEN_SETTINGS_GENERAL;
|
|
|
|
if (ui_do_button(&controls_button, "Controls", 0, 30, 250, 170, 48, draw_teewars_button))
|
|
|
|
screen = SCREEN_SETTINGS_CONTROLS;
|
|
|
|
if (ui_do_button(&video_button, "Video", 0, 30, 300, 170, 48, draw_teewars_button))
|
|
|
|
screen = SCREEN_SETTINGS_VIDEO;
|
|
|
|
if (ui_do_button(&sound_button, "Sound", 0, 30, 350, 170, 48, draw_teewars_button))
|
|
|
|
screen = SCREEN_SETTINGS_SOUND;
|
|
|
|
|
|
|
|
switch (screen)
|
|
|
|
{
|
|
|
|
case SCREEN_SETTINGS_GENERAL: settings_general_render(); break;
|
|
|
|
case SCREEN_SETTINGS_CONTROLS: settings_controls_render(); break;
|
|
|
|
case SCREEN_SETTINGS_VIDEO: settings_video_render(); break;
|
|
|
|
case SCREEN_SETTINGS_SOUND: settings_sound_render(); break;
|
|
|
|
}
|
|
|
|
|
2007-06-01 11:08:33 +00:00
|
|
|
// SAVE BUTTON
|
|
|
|
static int save_button;
|
|
|
|
if (ui_do_button(&save_button, "Save", 0, 482, 490, 128, 48, draw_teewars_button))
|
|
|
|
{
|
|
|
|
config = config_copy;
|
2007-06-01 12:02:27 +00:00
|
|
|
config_save("teewars.cfg");
|
2007-07-21 15:48:35 +00:00
|
|
|
screen = SCREEN_MAIN;
|
2007-06-01 11:08:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CANCEL BUTTON
|
|
|
|
static int cancel_button;
|
|
|
|
if (ui_do_button(&cancel_button, "Cancel", 0, 620, 490, 150, 48, draw_teewars_button))
|
2007-07-21 18:18:06 +00:00
|
|
|
{
|
|
|
|
snd_set_master_volume(config.volume / 255.0f);
|
2007-07-21 15:48:35 +00:00
|
|
|
screen = SCREEN_MAIN;
|
2007-07-21 18:18:06 +00:00
|
|
|
}
|
2007-06-01 02:21:46 +00:00
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-10 17:25:08 +00:00
|
|
|
extern double extra_kerning[256*256];
|
|
|
|
|
2007-07-21 15:48:35 +00:00
|
|
|
static int kerning_render()
|
2007-06-10 17:25:08 +00:00
|
|
|
{
|
|
|
|
static bool loaded = false;
|
2007-06-10 21:35:59 +00:00
|
|
|
static char text[32] = {0};
|
2007-06-10 17:25:08 +00:00
|
|
|
|
|
|
|
if (!loaded)
|
|
|
|
{
|
|
|
|
file_stream file;
|
|
|
|
|
|
|
|
if (file.open_r("kerning.txt"))
|
|
|
|
{
|
|
|
|
line_stream lstream(&file);
|
|
|
|
int i = 0;
|
|
|
|
char *line;
|
|
|
|
|
|
|
|
while ((line = lstream.get_line()))
|
|
|
|
extra_kerning[i++] = atof(line);
|
|
|
|
|
|
|
|
file.close();
|
|
|
|
}
|
|
|
|
|
2007-06-10 20:00:58 +00:00
|
|
|
if (file.open_r("tracking.txt"))
|
|
|
|
{
|
|
|
|
line_stream lstream(&file);
|
|
|
|
char *line;
|
|
|
|
|
|
|
|
for (int i = 0; i < 256; i++)
|
|
|
|
{
|
|
|
|
line = lstream.get_line();
|
|
|
|
current_font->m_CharStartTable[i] = atof(line);
|
|
|
|
line = lstream.get_line();
|
|
|
|
current_font->m_CharEndTable[i] = atof(line);
|
|
|
|
}
|
|
|
|
|
|
|
|
file.close();
|
|
|
|
}
|
|
|
|
|
2007-06-10 17:25:08 +00:00
|
|
|
loaded = true;
|
|
|
|
}
|
|
|
|
|
2007-06-10 21:35:59 +00:00
|
|
|
ui_do_edit_box(text, 160, 20, 300, 36, text, sizeof(text));
|
2007-06-10 17:25:08 +00:00
|
|
|
|
2007-06-10 21:35:59 +00:00
|
|
|
ui_do_label(160, 250, text, 70);
|
2007-06-10 17:25:08 +00:00
|
|
|
|
|
|
|
int len = strlen(text);
|
|
|
|
|
|
|
|
for (int i = 0; i < len-1; i++)
|
|
|
|
{
|
|
|
|
char s[3] = {0};
|
|
|
|
s[0] = text[i];
|
|
|
|
s[1] = text[i+1];
|
|
|
|
ui_do_label(10, 30 * i + 10, s, 45);
|
|
|
|
|
|
|
|
int index = s[0] + s[1] * 256;
|
|
|
|
|
|
|
|
// less
|
2007-07-16 16:48:16 +00:00
|
|
|
if (ui_do_button((void *)(100 + i * 2), "", 0, 50, 30 * i + 10 + 20, 16, 16, draw_single_part_button, (void *)GUI_MISC_SLIDER_BIG_ARROW_LEFT))
|
2007-06-10 17:25:08 +00:00
|
|
|
{
|
|
|
|
extra_kerning[index] -= 0.01;
|
|
|
|
}
|
|
|
|
|
|
|
|
// more
|
2007-07-16 16:48:16 +00:00
|
|
|
if (ui_do_button((void *)(100 + i * 2 + 1), "", 0, 66, 30 * i + 10 + 20, 16, 16, draw_single_part_button, (void *)GUI_MISC_SLIDER_BIG_ARROW_RIGHT))
|
2007-06-10 17:25:08 +00:00
|
|
|
{
|
|
|
|
extra_kerning[index] += 0.01;
|
|
|
|
}
|
|
|
|
|
|
|
|
char num[16];
|
|
|
|
sprintf(num, "(%f)", extra_kerning[index]);
|
2007-06-10 21:35:59 +00:00
|
|
|
ui_do_label(84, 30 * i + 30, num, 12);
|
2007-06-10 17:25:08 +00:00
|
|
|
}
|
|
|
|
|
2007-06-10 20:00:58 +00:00
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
char s[2] = {0};
|
|
|
|
s[0] = text[i];
|
|
|
|
|
|
|
|
ui_do_label(700, 35 * i + 10, s, 45);
|
|
|
|
|
|
|
|
gfx_blend_normal();
|
|
|
|
gfx_texture_set(-1);
|
|
|
|
gfx_quads_begin();
|
|
|
|
gfx_quads_setcolor(0,0,0,0.5);
|
|
|
|
gfx_quads_drawTL(700,35*i+20,1,30);
|
2007-06-11 19:59:29 +00:00
|
|
|
gfx_quads_drawTL(700+45*(current_font->m_CharEndTable[(int)s[0]]-current_font->m_CharStartTable[(int)s[0]]),35*i+20,1,30);
|
2007-06-10 20:00:58 +00:00
|
|
|
gfx_quads_end();
|
|
|
|
// less
|
2007-07-16 16:48:16 +00:00
|
|
|
if (ui_do_button((void *)(200 + i * 2), "", 0, 650, 35 * i + 10 + 15, 16, 16, draw_single_part_button, (void *)GUI_MISC_SLIDER_BIG_ARROW_LEFT))
|
2007-06-10 20:00:58 +00:00
|
|
|
{
|
2007-07-13 21:22:45 +00:00
|
|
|
current_font->m_CharStartTable[(int)s[0]] -= 0.01f;
|
2007-06-10 20:00:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// more
|
2007-07-16 16:48:16 +00:00
|
|
|
if (ui_do_button((void *)(200 + i * 2 + 1), "", 0, 666, 35 * i + 10 + 15, 16, 16, draw_single_part_button, (void *)GUI_MISC_SLIDER_BIG_ARROW_RIGHT))
|
2007-06-10 20:00:58 +00:00
|
|
|
{
|
2007-07-13 21:22:45 +00:00
|
|
|
current_font->m_CharStartTable[(int)s[0]] += 0.01f;
|
2007-06-10 20:00:58 +00:00
|
|
|
}
|
|
|
|
|
2007-06-10 21:35:59 +00:00
|
|
|
char num[16];
|
2007-06-11 19:59:29 +00:00
|
|
|
sprintf(num, "(%f)", current_font->m_CharStartTable[(int)s[0]]);
|
2007-06-10 21:35:59 +00:00
|
|
|
ui_do_label(645, 35 * i + 40, num, 12);
|
|
|
|
|
|
|
|
|
2007-06-10 20:00:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
// less
|
2007-07-16 16:48:16 +00:00
|
|
|
if (ui_do_button((void *)(300 + i * 2), "", 0, 750, 35 * i + 10 + 15, 16, 16, draw_single_part_button, (void *)GUI_MISC_SLIDER_BIG_ARROW_LEFT))
|
2007-06-10 20:00:58 +00:00
|
|
|
{
|
2007-07-13 21:22:45 +00:00
|
|
|
current_font->m_CharEndTable[(int)s[0]] -= 0.01f;
|
2007-06-10 20:00:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// more
|
2007-07-16 16:48:16 +00:00
|
|
|
if (ui_do_button((void *)(300 + i * 2 + 1), "", 0, 766, 35 * i + 10 + 15, 16, 16, draw_single_part_button, (void *)GUI_MISC_SLIDER_BIG_ARROW_RIGHT))
|
2007-06-10 20:00:58 +00:00
|
|
|
{
|
2007-07-13 21:22:45 +00:00
|
|
|
current_font->m_CharEndTable[(int)s[0]] += 0.01f;
|
2007-06-10 20:00:58 +00:00
|
|
|
}
|
|
|
|
|
2007-06-11 19:59:29 +00:00
|
|
|
sprintf(num, "(%f)", current_font->m_CharEndTable[(int)s[0]]);
|
2007-06-10 21:35:59 +00:00
|
|
|
ui_do_label(745, 35 * i + 40, num, 12);
|
2007-06-10 20:00:58 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-06-10 17:25:08 +00:00
|
|
|
// SAVE BUTTON
|
|
|
|
static int save_button;
|
2007-06-10 21:35:59 +00:00
|
|
|
if (ui_do_button(&save_button, "Save", 0, 482, 520, 128, 48, draw_teewars_button))
|
2007-06-10 17:25:08 +00:00
|
|
|
{
|
|
|
|
file_stream file;
|
|
|
|
|
|
|
|
if (file.open_w("kerning.txt"))
|
|
|
|
{
|
|
|
|
char t[16];
|
|
|
|
|
|
|
|
for (int i = 0; i < 256*256; i++)
|
|
|
|
{
|
|
|
|
sprintf(t, "%f\n", extra_kerning[i]);
|
|
|
|
file.write(t, strlen(t));
|
|
|
|
}
|
|
|
|
|
|
|
|
file.close();
|
|
|
|
}
|
|
|
|
|
2007-06-10 20:00:58 +00:00
|
|
|
if (file.open_w("tracking.txt"))
|
|
|
|
{
|
|
|
|
char t[16];
|
|
|
|
|
|
|
|
for (int i = 0; i < 256; i++)
|
|
|
|
{
|
|
|
|
sprintf(t, "%f\n", current_font->m_CharStartTable[i]);
|
|
|
|
file.write(t, strlen(t));
|
|
|
|
sprintf(t, "%f\n", current_font->m_CharEndTable[i]);
|
|
|
|
file.write(t, strlen(t));
|
|
|
|
}
|
|
|
|
|
|
|
|
file.close();
|
|
|
|
}
|
|
|
|
|
2007-06-10 17:25:08 +00:00
|
|
|
//screen = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CANCEL BUTTON
|
|
|
|
static int cancel_button;
|
2007-06-10 21:35:59 +00:00
|
|
|
if (ui_do_button(&cancel_button, "Cancel", 0, 620, 520, 150, 48, draw_teewars_button))
|
2007-07-21 15:48:35 +00:00
|
|
|
screen = SCREEN_MAIN;
|
2007-06-10 17:25:08 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-21 18:07:27 +00:00
|
|
|
static int menu_render()
|
2007-06-01 02:21:46 +00:00
|
|
|
{
|
|
|
|
// background color
|
2007-07-21 12:57:36 +00:00
|
|
|
gfx_clear(0.65f,0.78f,0.9f);
|
|
|
|
//gfx_clear(89/255.f,122/255.f,0.0);
|
2007-06-01 02:21:46 +00:00
|
|
|
|
|
|
|
// GUI coordsys
|
|
|
|
gfx_mapscreen(0,0,800.0f,600.0f);
|
|
|
|
|
|
|
|
static int64 start = time_get();
|
|
|
|
|
|
|
|
float t = double(time_get() - start) / double(time_freq());
|
2007-07-21 12:57:36 +00:00
|
|
|
gfx_mapscreen(0,0,1600.0f,1200.0f);
|
2007-07-21 21:08:28 +00:00
|
|
|
draw_background(t);
|
2007-07-21 12:57:36 +00:00
|
|
|
gfx_mapscreen(0,0,800.0f,600.0f);
|
2007-06-01 02:21:46 +00:00
|
|
|
|
2007-07-21 15:48:35 +00:00
|
|
|
if (screen != SCREEN_KERNING)
|
2007-06-10 21:35:59 +00:00
|
|
|
{
|
2007-07-21 21:08:28 +00:00
|
|
|
ui_do_image(teewars_banner_texture, 200, 20, 512, 128);
|
2007-06-10 21:35:59 +00:00
|
|
|
ui_do_label(20.0f, 600.0f-40.0f, "Version: " TEEWARS_VERSION, 36);
|
|
|
|
}
|
2007-06-01 02:21:46 +00:00
|
|
|
|
2007-06-11 19:59:29 +00:00
|
|
|
switch (screen)
|
|
|
|
{
|
2007-07-21 18:07:27 +00:00
|
|
|
case SCREEN_MAIN: return main_render();
|
2007-07-21 15:48:35 +00:00
|
|
|
case SCREEN_SETTINGS_GENERAL:
|
|
|
|
case SCREEN_SETTINGS_CONTROLS:
|
|
|
|
case SCREEN_SETTINGS_VIDEO:
|
|
|
|
case SCREEN_SETTINGS_SOUND: return settings_render();
|
|
|
|
case SCREEN_KERNING: return kerning_render();
|
|
|
|
default: dbg_msg("menu", "invalid screen selected..."); return 0;
|
2007-06-11 19:59:29 +00:00
|
|
|
}
|
2007-06-01 02:21:46 +00:00
|
|
|
}
|
|
|
|
|
2007-05-22 15:03:32 +00:00
|
|
|
void modmenu_init()
|
|
|
|
{
|
2007-06-10 15:19:04 +00:00
|
|
|
input::enable_char_cache();
|
|
|
|
input::enable_key_cache();
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-07-16 19:39:04 +00:00
|
|
|
// TODO: should be removed
|
2007-07-15 23:52:36 +00:00
|
|
|
current_font->font_texture = gfx_load_texture("data/big_font.png");
|
2007-06-01 02:21:46 +00:00
|
|
|
background_texture = gfx_load_texture("data/gui_bg.png");
|
2007-05-27 18:14:24 +00:00
|
|
|
gui_tileset_texture = gfx_load_texture("data/gui/gui_widgets.png");
|
2007-05-27 00:47:07 +00:00
|
|
|
teewars_banner_texture = gfx_load_texture("data/gui_logo.png");
|
2007-07-21 18:18:06 +00:00
|
|
|
cursor_texture = gfx_load_texture("data/gui/cursor.png");
|
2007-07-21 21:08:28 +00:00
|
|
|
cloud1_texture = gfx_load_texture("data/cloud-1.png");
|
|
|
|
cloud2_texture = gfx_load_texture("data/cloud-2.png");
|
|
|
|
cloud3_texture = gfx_load_texture("data/cloud-3.png");
|
2007-07-22 13:19:18 +00:00
|
|
|
menu_background_texture = gfx_load_texture("data/menu_background.png");
|
|
|
|
butterflies_texture = gfx_load_texture("data/menu_butterfly.png");
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-07-16 19:39:04 +00:00
|
|
|
// TODO: should be removed
|
2007-05-22 15:03:32 +00:00
|
|
|
music_menu = snd_load_wav("data/audio/Music_Menu.wav");
|
|
|
|
}
|
|
|
|
|
|
|
|
void modmenu_shutdown()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-07-21 18:07:27 +00:00
|
|
|
int modmenu_render()
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
|
|
|
static int mouse_x = 0;
|
|
|
|
static int mouse_y = 0;
|
|
|
|
|
|
|
|
if (music_menu_id == -1)
|
|
|
|
{
|
|
|
|
dbg_msg("menu", "no music is playing, so let's play some tunes!");
|
|
|
|
music_menu_id = snd_play(music_menu, SND_LOOP);
|
|
|
|
}
|
|
|
|
|
|
|
|
// handle mouse movement
|
2007-07-16 19:39:04 +00:00
|
|
|
float mx, my;
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
|
|
|
int rx, ry;
|
|
|
|
inp_mouse_relative(&rx, &ry);
|
|
|
|
mouse_x += rx;
|
|
|
|
mouse_y += ry;
|
|
|
|
if(mouse_x < 0) mouse_x = 0;
|
|
|
|
if(mouse_y < 0) mouse_y = 0;
|
|
|
|
if(mouse_x > gfx_screenwidth()) mouse_x = gfx_screenwidth();
|
|
|
|
if(mouse_y > gfx_screenheight()) mouse_y = gfx_screenheight();
|
|
|
|
|
|
|
|
// update the ui
|
2007-05-28 13:49:44 +00:00
|
|
|
mx = (mouse_x/(float)gfx_screenwidth())*800.0f;
|
|
|
|
my = (mouse_y/(float)gfx_screenheight())*600.0f;
|
2007-05-22 15:03:32 +00:00
|
|
|
|
|
|
|
int buttons = 0;
|
2007-06-10 15:19:04 +00:00
|
|
|
if(inp_key_pressed(input::mouse_1)) buttons |= 1;
|
|
|
|
if(inp_key_pressed(input::mouse_2)) buttons |= 2;
|
|
|
|
if(inp_key_pressed(input::mouse_3)) buttons |= 4;
|
2007-05-22 15:03:32 +00:00
|
|
|
|
|
|
|
ui_update(mx,my,mx*3.0f,my*3.0f,buttons);
|
|
|
|
}
|
|
|
|
|
2007-06-01 02:21:46 +00:00
|
|
|
//int r = menu_render(server_address, str, max_len);
|
2007-07-21 18:07:27 +00:00
|
|
|
int r = menu_render();
|
2007-05-22 15:03:32 +00:00
|
|
|
|
|
|
|
// render butt ugly mouse cursor
|
2007-07-16 19:39:04 +00:00
|
|
|
// TODO: render nice cursor
|
2007-07-21 18:18:06 +00:00
|
|
|
gfx_texture_set(cursor_texture);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_begin();
|
|
|
|
gfx_quads_setcolor(1,1,1,1);
|
2007-07-21 18:18:06 +00:00
|
|
|
gfx_quads_drawTL(mx,my,24,24);
|
2007-05-22 15:03:32 +00:00
|
|
|
gfx_quads_end();
|
|
|
|
|
|
|
|
if (r)
|
|
|
|
{
|
|
|
|
snd_stop(music_menu_id);
|
|
|
|
music_menu_id = -1;
|
|
|
|
}
|
|
|
|
|
2007-06-10 15:19:04 +00:00
|
|
|
input::clear_char();
|
|
|
|
input::clear_key();
|
2007-05-22 15:03:32 +00:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|