mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
foundation for widescreen support... still needs to fix ingame gui
This commit is contained in:
parent
f5066fe62b
commit
c896ce54ea
|
@ -281,6 +281,11 @@ int gfx_init()
|
|||
return 1;
|
||||
}
|
||||
|
||||
float gfx_screenaspect()
|
||||
{
|
||||
return gfx_screenwidth()/(float)gfx_screenheight();
|
||||
}
|
||||
|
||||
void gfx_clear_mask(int fill)
|
||||
{
|
||||
/*if(fill)
|
||||
|
|
|
@ -113,7 +113,7 @@ static float scale = 1.0f;
|
|||
#define MEMORY_SIZE 10*1024
|
||||
static struct rect memory[MEMORY_SIZE];
|
||||
static int memory_used = 0;
|
||||
static struct rect screen = { 0.0f, 0.0f, 800.0f, 600.0f };
|
||||
static struct rect screen = { 0.0f, 0.0f, 848.0f, 480.0f };
|
||||
|
||||
void ui_foreach_rect(rect_fun fun)
|
||||
{
|
||||
|
|
|
@ -114,6 +114,8 @@ int gfx_init();
|
|||
void gfx_shutdown();
|
||||
void gfx_swap();
|
||||
|
||||
float gfx_screenaspect();
|
||||
|
||||
int gfx_get_video_modes(VIDEO_MODE *list, int maxcount);
|
||||
void gfx_set_vsync(int val);
|
||||
|
||||
|
|
|
@ -43,6 +43,12 @@ enum
|
|||
CHATMODE_REMOTECONSOLE,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x, y, w, h;
|
||||
} RECT;
|
||||
RECT *ui2_screen();
|
||||
|
||||
static int chat_mode = CHATMODE_NONE;
|
||||
bool menu_active = false;
|
||||
bool menu_game_active = false;
|
||||
|
@ -526,14 +532,15 @@ extern int render_popup(const char *caption, const char *text, const char *butto
|
|||
static void render_loading(float percent)
|
||||
{
|
||||
gfx_clear(0.65f,0.78f,0.9f);
|
||||
gfx_mapscreen(0,0,800.0f,600.0f);
|
||||
RECT screen = *ui2_screen();
|
||||
gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);
|
||||
|
||||
float tw;
|
||||
|
||||
float w = 700;
|
||||
float h = 200;
|
||||
float x = 800/2-w/2;
|
||||
float y = 600/2-h/2;
|
||||
float x = screen.w/2-w/2;
|
||||
float y = screen.h/2-h/2;
|
||||
|
||||
gfx_blend_normal();
|
||||
|
||||
|
@ -1688,35 +1695,35 @@ int emoticon_selector_render()
|
|||
emoticon_selector_mouse.x += x;
|
||||
emoticon_selector_mouse.y += y;
|
||||
|
||||
if (length(emoticon_selector_mouse) > 70)
|
||||
emoticon_selector_mouse = normalize(emoticon_selector_mouse) * 70;
|
||||
if (length(emoticon_selector_mouse) > 140)
|
||||
emoticon_selector_mouse = normalize(emoticon_selector_mouse) * 140;
|
||||
|
||||
float selected_angle = get_angle(emoticon_selector_mouse) + 2*pi/24;
|
||||
if (selected_angle < 0)
|
||||
selected_angle += 2*pi;
|
||||
|
||||
//static bool mouse_down = false;
|
||||
bool return_now = false;
|
||||
int selected_emoticon = -1;
|
||||
|
||||
if (length(emoticon_selector_mouse) > 50)
|
||||
if (length(emoticon_selector_mouse) > 100)
|
||||
selected_emoticon = (int)(selected_angle / (2*pi) * 12.0f);
|
||||
|
||||
if(!inp_key_pressed(config.key_emoticon))
|
||||
{
|
||||
return_now = true;
|
||||
emoticon_selector_active = false;
|
||||
//emoticon_selector_inactive_override = true;
|
||||
}
|
||||
|
||||
gfx_mapscreen(0,0,400,300);
|
||||
RECT screen = *ui2_screen();
|
||||
|
||||
gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);
|
||||
|
||||
gfx_blend_normal();
|
||||
|
||||
gfx_texture_set(-1);
|
||||
gfx_quads_begin();
|
||||
gfx_setcolor(0,0,0,0.3f);
|
||||
draw_circle(200, 150, 80, 64);
|
||||
draw_circle(screen.w/2, screen.h/2, 160, 64);
|
||||
gfx_quads_end();
|
||||
|
||||
gfx_texture_set(data->images[IMAGE_EMOTICONS].id);
|
||||
|
@ -1730,12 +1737,12 @@ int emoticon_selector_render()
|
|||
|
||||
bool selected = selected_emoticon == i;
|
||||
|
||||
float size = selected ? 48 : 32;
|
||||
float size = selected ? 96 : 64;
|
||||
|
||||
float nudge_x = 60 * cos(angle);
|
||||
float nudge_y = 60 * sin(angle);
|
||||
float nudge_x = 120 * cos(angle);
|
||||
float nudge_y = 120 * sin(angle);
|
||||
select_sprite(SPRITE_OOP + i);
|
||||
gfx_quads_draw(200 + nudge_x, 150 + nudge_y, size, size);
|
||||
gfx_quads_draw(screen.w/2 + nudge_x, screen.h/2 + nudge_y, size, size);
|
||||
}
|
||||
|
||||
gfx_quads_end();
|
||||
|
@ -1743,7 +1750,7 @@ int emoticon_selector_render()
|
|||
gfx_texture_set(data->images[IMAGE_CURSOR].id);
|
||||
gfx_quads_begin();
|
||||
gfx_setcolor(1,1,1,1);
|
||||
gfx_quads_drawTL(emoticon_selector_mouse.x+200,emoticon_selector_mouse.y+150,12,12);
|
||||
gfx_quads_drawTL(emoticon_selector_mouse.x+screen.w/2,emoticon_selector_mouse.y+screen.h/2,24,24);
|
||||
gfx_quads_end();
|
||||
|
||||
return return_now ? selected_emoticon : -1;
|
||||
|
@ -1910,9 +1917,11 @@ void render_scoreboard(float x, float y, float w, int team, const char *title)
|
|||
|
||||
void mapscreen_to_world(float center_x, float center_y, float zoom)
|
||||
{
|
||||
const float default_zoom = 3.0f;
|
||||
float width = 400*default_zoom*zoom;
|
||||
float height = 300*default_zoom*zoom;
|
||||
RECT screen = *ui2_screen();
|
||||
|
||||
const float default_zoom = 1.5f;
|
||||
float width = screen.w*default_zoom*zoom;
|
||||
float height = screen.h*default_zoom*zoom;
|
||||
gfx_mapscreen(center_x-width/2, center_y-height/2, center_x+width/2, center_y+height/2);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,13 +89,21 @@ typedef struct
|
|||
float x, y, w, h;
|
||||
} RECT;
|
||||
|
||||
//static float scale = 1.0f;
|
||||
static RECT screen = { 0.0f, 0.0f, 800.0f, 600.0f };
|
||||
static RECT screen = { 0.0f, 0.0f, 848.0f, 480.0f };
|
||||
|
||||
extern void select_sprite(int id, int flags=0, int sx=0, int sy=0);
|
||||
|
||||
RECT *ui2_screen()
|
||||
{
|
||||
float aspect = gfx_screenaspect();
|
||||
float w, h;
|
||||
|
||||
h = 600;
|
||||
w = aspect*h;
|
||||
|
||||
screen.w = w;
|
||||
screen.h = h;
|
||||
|
||||
return &screen;
|
||||
}
|
||||
|
||||
|
@ -1625,7 +1633,8 @@ int menu2_render()
|
|||
return 0;
|
||||
}
|
||||
|
||||
gfx_mapscreen(0,0,800,600);
|
||||
RECT screen = *ui2_screen();
|
||||
gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);
|
||||
|
||||
static bool first = true;
|
||||
if(first)
|
||||
|
@ -1649,7 +1658,6 @@ int menu2_render()
|
|||
color_tabbar_active = color_tabbar_active_outgame;
|
||||
}
|
||||
|
||||
RECT screen = *ui2_screen();
|
||||
RECT tab_bar;
|
||||
RECT main_view;
|
||||
|
||||
|
@ -1799,6 +1807,7 @@ void modmenu_render()
|
|||
static int mouse_x = 0;
|
||||
static int mouse_y = 0;
|
||||
|
||||
|
||||
// handle mouse movement
|
||||
float mx, my;
|
||||
{
|
||||
|
@ -1812,8 +1821,9 @@ void modmenu_render()
|
|||
if(mouse_y > gfx_screenheight()) mouse_y = gfx_screenheight();
|
||||
|
||||
// update the ui
|
||||
mx = (mouse_x/(float)gfx_screenwidth())*800.0f;
|
||||
my = (mouse_y/(float)gfx_screenheight())*600.0f;
|
||||
RECT *screen = ui2_screen();
|
||||
mx = (mouse_x/(float)gfx_screenwidth())*screen->w;
|
||||
my = (mouse_y/(float)gfx_screenheight())*screen->h;
|
||||
|
||||
int buttons = 0;
|
||||
if(inp_key_pressed(KEY_MOUSE_1)) buttons |= 1;
|
||||
|
|
Loading…
Reference in a new issue