mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Merge branch 'master' of https://github.com/SushiTee/teeworlds
This commit is contained in:
commit
cb9d6032ff
BIN
data/menu_buttons.png
Normal file
BIN
data/menu_buttons.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 919 B |
BIN
data/menu_fold.png
Normal file
BIN
data/menu_fold.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -233,6 +233,8 @@ image_fileicons = Image("fileicons", "file_icons.png")
|
|||
image_guibuttons = Image("guibuttons", "gui_buttons.png")
|
||||
image_guiicons = Image("guiicons", "gui_icons.png")
|
||||
image_browsericons = Image("browsericons", "gui_browser_icons.png")
|
||||
image_checkboxicons = Image("checkboxicons", "menu_buttons.png")
|
||||
image_foldicons = Image("foldicons", "menu_fold.png")
|
||||
|
||||
container.images.Add(image_null)
|
||||
container.images.Add(image_game)
|
||||
|
@ -251,6 +253,8 @@ container.images.Add(image_guiicons)
|
|||
container.images.Add(image_browsericons)
|
||||
container.images.Add(Image("no_skinpart", "no_skinpart.png"))
|
||||
container.images.Add(Image("hlpicker", "hlpicker.png"))
|
||||
container.images.Add(image_checkboxicons)
|
||||
container.images.Add(image_foldicons)
|
||||
|
||||
container.pickups.Add(Pickup("health"))
|
||||
container.pickups.Add(Pickup("armor"))
|
||||
|
@ -274,6 +278,8 @@ set_fileicons = SpriteSet("fileicons", image_fileicons, 8, 1)
|
|||
set_guibuttons = SpriteSet("guibuttons", image_guibuttons, 12, 4)
|
||||
set_guiicons = SpriteSet("guiicons", image_guiicons, 8, 2)
|
||||
set_browsericons = SpriteSet("browsericons", image_browsericons, 14, 1)
|
||||
set_checkboxicons = SpriteSet("checkboxicons", image_checkboxicons, 2, 1)
|
||||
set_foldicons = SpriteSet("foldicons", image_foldicons, 2, 1)
|
||||
|
||||
container.spritesets.Add(set_particles)
|
||||
container.spritesets.Add(set_game)
|
||||
|
@ -290,6 +296,8 @@ container.spritesets.Add(set_fileicons)
|
|||
container.spritesets.Add(set_guibuttons)
|
||||
container.spritesets.Add(set_guiicons)
|
||||
container.spritesets.Add(set_browsericons)
|
||||
container.spritesets.Add(set_checkboxicons)
|
||||
container.spritesets.Add(set_foldicons)
|
||||
|
||||
container.sprites.Add(Sprite("part_slice", set_particles, 0,0,1,1))
|
||||
container.sprites.Add(Sprite("part_ball", set_particles, 1,0,1,1))
|
||||
|
@ -446,6 +454,12 @@ container.sprites.Add(Sprite("browsericon_star_inactive", set_browsericons, 11,0
|
|||
container.sprites.Add(Sprite("browsericon_heart_active", set_browsericons, 12,0,1,1))
|
||||
container.sprites.Add(Sprite("browsericon_heart_inactive", set_browsericons, 13,0,1,1))
|
||||
|
||||
container.sprites.Add(Sprite("checkbox_active", set_checkboxicons, 0,0,1,1))
|
||||
container.sprites.Add(Sprite("checkbox_inactive", set_checkboxicons, 1,0,1,1))
|
||||
|
||||
container.sprites.Add(Sprite("fold_expanded", set_foldicons, 0,0,1,1))
|
||||
container.sprites.Add(Sprite("fold_collapsed", set_foldicons, 1,0,1,1))
|
||||
|
||||
anim = Animation("base")
|
||||
anim.body.frames.Add(AnimKeyframe(0, 0, -4, 0))
|
||||
anim.back_foot.frames.Add(AnimKeyframe(0, 0, 10, 0))
|
||||
|
|
|
@ -388,7 +388,7 @@ void CCommandProcessor_SDL_OpenGL::RunBuffer(CCommandBuffer *pBuffer)
|
|||
|
||||
// ------------ CGraphicsBackend_SDL_OpenGL
|
||||
|
||||
int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags)
|
||||
int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight)
|
||||
{
|
||||
if(!SDL_WasInit(SDL_INIT_VIDEO))
|
||||
{
|
||||
|
@ -414,6 +414,10 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Width, int *Height
|
|||
*Height = pInfo->current_h;
|
||||
}
|
||||
|
||||
// store desktop resolution for settings reset button
|
||||
*pDesktopWidth = pInfo->current_w;
|
||||
*pDesktopHeight = pInfo->current_h;
|
||||
|
||||
// set flags
|
||||
int SdlFlags = SDL_OPENGL;
|
||||
if(Flags&IGraphicsBackend::INITFLAG_RESIZABLE)
|
||||
|
|
|
@ -198,7 +198,7 @@ class CGraphicsBackend_SDL_OpenGL : public CGraphicsBackend_Threaded
|
|||
ICommandProcessor *m_pProcessor;
|
||||
SGLContext m_GLContext;
|
||||
public:
|
||||
virtual int Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags);
|
||||
virtual int Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight);
|
||||
virtual int Shutdown();
|
||||
|
||||
virtual void Minimize();
|
||||
|
|
|
@ -37,27 +37,18 @@
|
|||
|
||||
|
||||
static CVideoMode g_aFakeModes[] = {
|
||||
{320,240,8,8,8}, {400,300,8,8,8}, {640,480,8,8,8},
|
||||
{320,200,8,8,8}, {320,240,8,8,8}, {400,300,8,8,8},
|
||||
{512,384,8,8,8}, {640,400,8,8,8}, {640,480,8,8,8},
|
||||
{720,400,8,8,8}, {768,576,8,8,8}, {800,600,8,8,8},
|
||||
{1024,600,8,8,8}, {1024,768,8,8,8}, {1152,864,8,8,8},
|
||||
{1280,768,8,8,8}, {1280,800,8,8,8}, {1280,960,8,8,8},
|
||||
{1280,1024,8,8,8}, {1368,768,8,8,8}, {1400,1050,8,8,8},
|
||||
{1440,900,8,8,8}, {1440,1050,8,8,8}, {1600,1000,8,8,8},
|
||||
{1600,1200,8,8,8}, {1680,1050,8,8,8}, {1792,1344,8,8,8},
|
||||
{1800,1440,8,8,8}, {1856,1392,8,8,8}, {1920,1080,8,8,8},
|
||||
{1920,1200,8,8,8}, {1920,1440,8,8,8}, {1920,2400,8,8,8},
|
||||
{2048,1536,8,8,8},
|
||||
|
||||
{320,240,5,6,5}, {400,300,5,6,5}, {640,480,5,6,5},
|
||||
{720,400,5,6,5}, {768,576,5,6,5}, {800,600,5,6,5},
|
||||
{1024,600,5,6,5}, {1024,768,5,6,5}, {1152,864,5,6,5},
|
||||
{1280,768,5,6,5}, {1280,800,5,6,5}, {1280,960,5,6,5},
|
||||
{1280,1024,5,6,5}, {1368,768,5,6,5}, {1400,1050,5,6,5},
|
||||
{1440,900,5,6,5}, {1440,1050,5,6,5}, {1600,1000,5,6,5},
|
||||
{1600,1200,5,6,5}, {1680,1050,5,6,5}, {1792,1344,5,6,5},
|
||||
{1800,1440,5,6,5}, {1856,1392,5,6,5}, {1920,1080,5,6,5},
|
||||
{1920,1200,5,6,5}, {1920,1440,5,6,5}, {1920,2400,5,6,5},
|
||||
{2048,1536,5,6,5}
|
||||
{1280,600,8,8,8}, {1280,720,8,8,8}, {1280,768,8,8,8},
|
||||
{1280,800,8,8,8}, {1280,960,8,8,8}, {1280,1024,8,8,8},
|
||||
{1360,768,8,8,8}, {1366,768,8,8,8}, {1368,768,8,8,8},
|
||||
{1400,1050,8,8,8}, {1440,900,8,8,8}, {1440,1050,8,8,8},
|
||||
{1600,900,8,8,8}, {1600,1000,8,8,8}, {1600,1200,8,8,8},
|
||||
{1680,1050,8,8,8}, {1792,1344,8,8,8}, {1800,1440,8,8,8},
|
||||
{1856,1392,8,8,8}, {1920,1080,8,8,8}, {1920,1200,8,8,8},
|
||||
{1920,1440,8,8,8}, {1920,2400,8,8,8}, {2048,1536,8,8,8}
|
||||
};
|
||||
|
||||
void CGraphics_OpenGL::Flush()
|
||||
|
@ -594,6 +585,17 @@ void CGraphics_OpenGL::SetColor(float r, float g, float b, float a)
|
|||
SetColorVertex(Array, 4);
|
||||
}
|
||||
|
||||
void CGraphics_OpenGL::SetColor4(vec4 TopLeft, vec4 TopRight, vec4 BottomLeft, vec4 BottomRight)
|
||||
{
|
||||
dbg_assert(m_Drawing != 0, "called Graphics()->SetColor without begin");
|
||||
CColorVertex Array[4] = {
|
||||
CColorVertex(0, TopLeft.r, TopLeft.g, TopLeft.b, TopLeft.a),
|
||||
CColorVertex(1, TopRight.r, TopRight.g, TopRight.b, TopRight.a),
|
||||
CColorVertex(2, BottomRight.r, BottomRight.g, BottomRight.b, BottomRight.a),
|
||||
CColorVertex(3, BottomLeft.r, BottomLeft.g, BottomLeft.b, BottomLeft.a)};
|
||||
SetColorVertex(Array, 4);
|
||||
}
|
||||
|
||||
void CGraphics_OpenGL::QuadsSetSubset(float TlU, float TlV, float BrU, float BrV)
|
||||
{
|
||||
dbg_assert(m_Drawing == DRAWING_QUADS, "called Graphics()->QuadsSetSubset without begin");
|
||||
|
@ -785,6 +787,10 @@ int CGraphics_SDL::TryInit()
|
|||
m_ScreenWidth = g_Config.m_GfxScreenWidth;
|
||||
m_ScreenHeight = g_Config.m_GfxScreenHeight;
|
||||
|
||||
// store desktop resolution for settings reset button
|
||||
m_DesktopScreenWidth = pInfo->current_w;
|
||||
m_DesktopScreenHeight = pInfo->current_h;
|
||||
|
||||
// set flags
|
||||
int Flags = SDL_OPENGL;
|
||||
if(g_Config.m_DbgResizable)
|
||||
|
|
|
@ -110,6 +110,7 @@ public:
|
|||
|
||||
virtual void SetColorVertex(const CColorVertex *pArray, int Num);
|
||||
virtual void SetColor(float r, float g, float b, float a);
|
||||
virtual void SetColor4(vec4 TopLeft, vec4 TopRight, vec4 BottomLeft, vec4 BottomRight);
|
||||
|
||||
virtual void QuadsSetSubset(float TlU, float TlV, float BrU, float BrV);
|
||||
virtual void QuadsSetSubsetFree(
|
||||
|
@ -147,6 +148,9 @@ public:
|
|||
|
||||
virtual int GetVideoModes(CVideoMode *pModes, int MaxModes);
|
||||
|
||||
virtual int GetDesktopScreenWidth() { return m_DesktopScreenWidth; }
|
||||
virtual int GetDesktopScreenHeight() { return m_DesktopScreenHeight; }
|
||||
|
||||
// syncronization
|
||||
virtual void InsertSignal(semaphore *pSemaphore);
|
||||
virtual bool IsIdle();
|
||||
|
|
|
@ -19,27 +19,18 @@
|
|||
#include "graphics_threaded.h"
|
||||
|
||||
static CVideoMode g_aFakeModes[] = {
|
||||
{320,240,8,8,8}, {400,300,8,8,8}, {640,480,8,8,8},
|
||||
{320,200,8,8,8}, {320,240,8,8,8}, {400,300,8,8,8},
|
||||
{512,384,8,8,8}, {640,400,8,8,8}, {640,480,8,8,8},
|
||||
{720,400,8,8,8}, {768,576,8,8,8}, {800,600,8,8,8},
|
||||
{1024,600,8,8,8}, {1024,768,8,8,8}, {1152,864,8,8,8},
|
||||
{1280,768,8,8,8}, {1280,800,8,8,8}, {1280,960,8,8,8},
|
||||
{1280,1024,8,8,8}, {1368,768,8,8,8}, {1400,1050,8,8,8},
|
||||
{1440,900,8,8,8}, {1440,1050,8,8,8}, {1600,1000,8,8,8},
|
||||
{1600,1200,8,8,8}, {1680,1050,8,8,8}, {1792,1344,8,8,8},
|
||||
{1800,1440,8,8,8}, {1856,1392,8,8,8}, {1920,1080,8,8,8},
|
||||
{1920,1200,8,8,8}, {1920,1440,8,8,8}, {1920,2400,8,8,8},
|
||||
{2048,1536,8,8,8},
|
||||
|
||||
{320,240,5,6,5}, {400,300,5,6,5}, {640,480,5,6,5},
|
||||
{720,400,5,6,5}, {768,576,5,6,5}, {800,600,5,6,5},
|
||||
{1024,600,5,6,5}, {1024,768,5,6,5}, {1152,864,5,6,5},
|
||||
{1280,768,5,6,5}, {1280,800,5,6,5}, {1280,960,5,6,5},
|
||||
{1280,1024,5,6,5}, {1368,768,5,6,5}, {1400,1050,5,6,5},
|
||||
{1440,900,5,6,5}, {1440,1050,5,6,5}, {1600,1000,5,6,5},
|
||||
{1600,1200,5,6,5}, {1680,1050,5,6,5}, {1792,1344,5,6,5},
|
||||
{1800,1440,5,6,5}, {1856,1392,5,6,5}, {1920,1080,5,6,5},
|
||||
{1920,1200,5,6,5}, {1920,1440,5,6,5}, {1920,2400,5,6,5},
|
||||
{2048,1536,5,6,5}
|
||||
{1280,600,8,8,8}, {1280,720,8,8,8}, {1280,768,8,8,8},
|
||||
{1280,800,8,8,8}, {1280,960,8,8,8}, {1280,1024,8,8,8},
|
||||
{1360,768,8,8,8}, {1366,768,8,8,8}, {1368,768,8,8,8},
|
||||
{1400,1050,8,8,8}, {1440,900,8,8,8}, {1440,1050,8,8,8},
|
||||
{1600,900,8,8,8}, {1600,1000,8,8,8}, {1600,1200,8,8,8},
|
||||
{1680,1050,8,8,8}, {1792,1344,8,8,8}, {1800,1440,8,8,8},
|
||||
{1856,1392,8,8,8}, {1920,1080,8,8,8}, {1920,1200,8,8,8},
|
||||
{1920,1440,8,8,8}, {1920,2400,8,8,8}, {2048,1536,8,8,8}
|
||||
};
|
||||
|
||||
void CGraphics_Threaded::FlushVertices()
|
||||
|
@ -571,6 +562,17 @@ void CGraphics_Threaded::SetColor(float r, float g, float b, float a)
|
|||
SetColorVertex(Array, 4);
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::SetColor4(vec4 TopLeft, vec4 TopRight, vec4 BottomLeft, vec4 BottomRight)
|
||||
{
|
||||
dbg_assert(m_Drawing != 0, "called Graphics()->SetColor without begin");
|
||||
CColorVertex Array[4] = {
|
||||
CColorVertex(0, TopLeft.r, TopLeft.g, TopLeft.b, TopLeft.a),
|
||||
CColorVertex(1, TopRight.r, TopRight.g, TopRight.b, TopRight.a),
|
||||
CColorVertex(2, BottomRight.r, BottomRight.g, BottomRight.b, BottomRight.a),
|
||||
CColorVertex(3, BottomLeft.r, BottomLeft.g, BottomLeft.b, BottomLeft.a)};
|
||||
SetColorVertex(Array, 4);
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::QuadsSetSubset(float TlU, float TlV, float BrU, float BrV)
|
||||
{
|
||||
dbg_assert(m_Drawing == DRAWING_QUADS, "called Graphics()->QuadsSetSubset without begin");
|
||||
|
@ -722,7 +724,7 @@ int CGraphics_Threaded::IssueInit()
|
|||
if(g_Config.m_GfxVsync) Flags |= IGraphicsBackend::INITFLAG_VSYNC;
|
||||
if(g_Config.m_DbgResizable) Flags |= IGraphicsBackend::INITFLAG_RESIZABLE;
|
||||
|
||||
return m_pBackend->Init("Teeworlds", &g_Config.m_GfxScreenWidth, &g_Config.m_GfxScreenHeight, g_Config.m_GfxFsaaSamples, Flags);
|
||||
return m_pBackend->Init("Teeworlds", &g_Config.m_GfxScreenWidth, &g_Config.m_GfxScreenHeight, g_Config.m_GfxFsaaSamples, Flags, &m_DesktopScreenWidth, &m_DesktopScreenHeight);
|
||||
}
|
||||
|
||||
int CGraphics_Threaded::InitWindow()
|
||||
|
|
|
@ -298,7 +298,7 @@ public:
|
|||
|
||||
virtual ~IGraphicsBackend() {}
|
||||
|
||||
virtual int Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags) = 0;
|
||||
virtual int Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight) = 0;
|
||||
virtual int Shutdown() = 0;
|
||||
|
||||
virtual void Minimize() = 0;
|
||||
|
@ -415,6 +415,7 @@ public:
|
|||
|
||||
virtual void SetColorVertex(const CColorVertex *pArray, int Num);
|
||||
virtual void SetColor(float r, float g, float b, float a);
|
||||
virtual void SetColor4(vec4 TopLeft, vec4 TopRight, vec4 BottomLeft, vec4 BottomRight);
|
||||
|
||||
virtual void QuadsSetSubset(float TlU, float TlV, float BrU, float BrV);
|
||||
virtual void QuadsSetSubsetFree(
|
||||
|
@ -440,6 +441,9 @@ public:
|
|||
|
||||
virtual int GetVideoModes(CVideoMode *pModes, int MaxModes);
|
||||
|
||||
virtual int GetDesktopScreenWidth() { return m_DesktopScreenWidth; }
|
||||
virtual int GetDesktopScreenHeight() { return m_DesktopScreenHeight; }
|
||||
|
||||
// syncronization
|
||||
virtual void InsertSignal(semaphore *pSemaphore);
|
||||
virtual bool IsIdle();
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#ifndef ENGINE_GRAPHICS_H
|
||||
#define ENGINE_GRAPHICS_H
|
||||
|
||||
#include <base/vmath.h>
|
||||
|
||||
#include "kernel.h"
|
||||
|
||||
|
||||
|
@ -42,6 +44,8 @@ class CVideoMode
|
|||
public:
|
||||
int m_Width, m_Height;
|
||||
int m_Red, m_Green, m_Blue;
|
||||
|
||||
bool operator<(const CVideoMode &Other) { return Other.m_Width < m_Width; }
|
||||
};
|
||||
|
||||
class IGraphics : public IInterface
|
||||
|
@ -50,6 +54,8 @@ class IGraphics : public IInterface
|
|||
protected:
|
||||
int m_ScreenWidth;
|
||||
int m_ScreenHeight;
|
||||
int m_DesktopScreenWidth;
|
||||
int m_DesktopScreenHeight;
|
||||
public:
|
||||
/* Constants: Texture Loading Flags
|
||||
TEXLOAD_NORESAMPLE - Prevents the texture from any resampling
|
||||
|
@ -147,10 +153,14 @@ public:
|
|||
};
|
||||
virtual void SetColorVertex(const CColorVertex *pArray, int Num) = 0;
|
||||
virtual void SetColor(float r, float g, float b, float a) = 0;
|
||||
virtual void SetColor4(vec4 TopLeft, vec4 TopRight, vec4 BottomLeft, vec4 BottomRight) = 0;
|
||||
|
||||
virtual void TakeScreenshot(const char *pFilename) = 0;
|
||||
virtual int GetVideoModes(CVideoMode *pModes, int MaxModes) = 0;
|
||||
|
||||
virtual int GetDesktopScreenWidth() = 0;
|
||||
virtual int GetDesktopScreenHeight() = 0;
|
||||
|
||||
virtual void Swap() = 0;
|
||||
|
||||
// syncronization
|
||||
|
|
|
@ -62,7 +62,6 @@ MACRO_CONFIG_INT(GfxScreenHeight, gfx_screen_height, 0, 0, 0, CFGFLAG_SAVE|CFGFL
|
|||
MACRO_CONFIG_INT(GfxBorderless, gfx_borderless, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Borderless window (not to be used with fullscreen)")
|
||||
MACRO_CONFIG_INT(GfxFullscreen, gfx_fullscreen, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Fullscreen")
|
||||
MACRO_CONFIG_INT(GfxAlphabits, gfx_alphabits, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Alpha bits for framebuffer (fullscreen only)")
|
||||
MACRO_CONFIG_INT(GfxColorDepth, gfx_color_depth, 24, 16, 24, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Colors bits for framebuffer (fullscreen only)")
|
||||
MACRO_CONFIG_INT(GfxClear, gfx_clear, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Clear screen before rendering")
|
||||
MACRO_CONFIG_INT(GfxVsync, gfx_vsync, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Vertical sync")
|
||||
MACRO_CONFIG_INT(GfxDisplayAllModes, gfx_display_all_modes, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "")
|
||||
|
|
|
@ -204,7 +204,7 @@ void CMapLayers::OnRender()
|
|||
}
|
||||
|
||||
// skip rendering if detail layers if not wanted
|
||||
if(pLayer->m_Flags&LAYERFLAG_DETAIL && !g_Config.m_GfxHighDetail && !IsGameLayer)
|
||||
if(pLayer->m_Flags&LAYERFLAG_DETAIL && !g_Config.m_GfxHighDetail && !IsGameLayer && (Client()->State() == IClient::STATE_ONLINE || Client()->State() == IClient::STATE_DEMOPLAYBACK))
|
||||
continue;
|
||||
|
||||
if(m_Type == -1)
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <engine/editor.h>
|
||||
#include <engine/engine.h>
|
||||
#include <engine/friends.h>
|
||||
#include <engine/graphics.h>
|
||||
#include <engine/keys.h>
|
||||
#include <engine/serverbrowser.h>
|
||||
#include <engine/storage.h>
|
||||
|
@ -33,7 +32,7 @@
|
|||
#include "skins.h"
|
||||
|
||||
float CMenus::ms_ButtonHeight = 25.0f;
|
||||
float CMenus::ms_ListheaderHeight = 17.0f;
|
||||
float CMenus::ms_ListheaderHeight = 20.0f;
|
||||
float CMenus::ms_FontmodHeight = 0.8f;
|
||||
|
||||
IInput::CEvent CMenus::m_aInputEvents[MAX_INPUTEVENTS];
|
||||
|
@ -48,8 +47,7 @@ CMenus::CMenus()
|
|||
|
||||
m_NeedRestartGraphics = false;
|
||||
m_NeedRestartSound = false;
|
||||
m_TeePartSelection = NO_SELECTION;
|
||||
m_TeePartsColorSelection = NO_SELECTION;
|
||||
m_TeePartSelected = 0;
|
||||
m_aSaveSkinName[0] = 0;
|
||||
m_MenuActive = true;
|
||||
m_UseMouseButtons = true;
|
||||
|
@ -125,12 +123,17 @@ int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const
|
|||
{
|
||||
float Seconds = 0.6f; // 0.6 seconds for fade
|
||||
float *pFade = ButtonFade(pID, Seconds);
|
||||
float FadeVal = *pFade/Seconds;
|
||||
|
||||
RenderTools()->DrawUIRect(pRect, vec4(1.0f , 1.0f, 1.0f, 0.5f+(*pFade/Seconds)*0.25f), Corners, r);
|
||||
RenderTools()->DrawUIRect(pRect, vec4(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f+FadeVal*0.5f), Corners, r);
|
||||
CUIRect Temp;
|
||||
pRect->HMargin(pRect->h>=20.0f?2.0f:1.0f, &Temp);
|
||||
Temp.HMargin((Temp.h*FontFactor)/2.0f, &Temp);
|
||||
TextRender()->TextColor(1.0f-FadeVal, 1.0f-FadeVal, 1.0f-FadeVal, 1.0f);
|
||||
TextRender()->TextOutlineColor(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f);
|
||||
UI()->DoLabel(&Temp, pText, Temp.h*ms_FontmodHeight, 0);
|
||||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
|
||||
return UI()->DoButtonLogic(pID, pText, Checked, pRect);
|
||||
}
|
||||
|
||||
|
@ -138,8 +141,9 @@ int CMenus::DoButton_MenuImage(const void *pID, const char *pText, int Checked,
|
|||
{
|
||||
float Seconds = 0.6f; // 0.6 seconds for fade
|
||||
float *pFade = ButtonFade(pID, Seconds);
|
||||
float FadeVal = *pFade/Seconds;
|
||||
|
||||
RenderTools()->DrawUIRect(pRect, vec4(1.0f , 1.0f, 1.0f, 0.5f+(*pFade/Seconds)*0.25f), CUI::CORNER_ALL, r);
|
||||
RenderTools()->DrawUIRect(pRect, vec4(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f+FadeVal*0.5f), CUI::CORNER_ALL, r);
|
||||
CUIRect Text, Image;
|
||||
pRect->VSplitRight(pRect->h*4.0f, &Text, &Image); // always correct ratio for image
|
||||
|
||||
|
@ -166,22 +170,31 @@ int CMenus::DoButton_MenuImage(const void *pID, const char *pText, int Checked,
|
|||
|
||||
}
|
||||
|
||||
pRect->HMargin(pRect->h>=20.0f?2.0f:1.0f, &Text);
|
||||
Text.HMargin(pRect->h>=20.0f?2.0f:1.0f, &Text);
|
||||
Text.HMargin((Text.h*FontFactor)/2.0f, &Text);
|
||||
Text.VSplitLeft(r, 0, &Text);
|
||||
UI()->DoLabel(&Text, pText, Text.h*ms_FontmodHeight, -1);
|
||||
TextRender()->TextColor(1.0f-FadeVal, 1.0f-FadeVal, 1.0f-FadeVal, 1.0f);
|
||||
TextRender()->TextOutlineColor(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f);
|
||||
UI()->DoLabel(&Text, pText, Text.h*ms_FontmodHeight, 0);
|
||||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
|
||||
return UI()->DoButtonLogic(pID, pText, Checked, pRect);
|
||||
}
|
||||
|
||||
void CMenus::DoButton_KeySelect(const void *pID, const char *pText, int Checked, const CUIRect *pRect)
|
||||
{
|
||||
float Seconds = 0.6f; // 0.6 seconds for fade
|
||||
float *pFade = ButtonFade(pID, Seconds);
|
||||
float *pFade = ButtonFade(pID, Seconds, Checked);
|
||||
float FadeVal = *pFade/Seconds;
|
||||
|
||||
RenderTools()->DrawUIRect(pRect, vec4(1.0f , 1.0f, 1.0f, 0.5f+(*pFade/Seconds)*0.25f), CUI::CORNER_ALL, 5.0f);
|
||||
RenderTools()->DrawUIRect(pRect, vec4(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f+FadeVal*0.5f), CUI::CORNER_ALL, 5.0f);
|
||||
CUIRect Temp;
|
||||
pRect->HMargin(1.0f, &Temp);
|
||||
TextRender()->TextColor(1.0f-FadeVal, 1.0f-FadeVal, 1.0f-FadeVal, 1.0f);
|
||||
TextRender()->TextOutlineColor(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f);
|
||||
UI()->DoLabel(&Temp, pText, Temp.h*ms_FontmodHeight, 0);
|
||||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
|
||||
}
|
||||
|
||||
int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners)
|
||||
|
@ -202,17 +215,21 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co
|
|||
return UI()->DoButtonLogic(pID, pText, Checked, pRect);
|
||||
}
|
||||
|
||||
int CMenus::DoButton_MenuTabTop(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners)
|
||||
int CMenus::DoButton_MenuTabTop(const void *pID, const char *pText, int Checked, const CUIRect *pRect, float r, float FontFactor, int Corners)
|
||||
{
|
||||
float Seconds = 0.6f; // 0.6 seconds for fade
|
||||
float *pFade = ButtonFade(pID, Seconds, Checked);
|
||||
float FadeVal = *pFade/Seconds;
|
||||
|
||||
RenderTools()->DrawUIRect(pRect, vec4(1.0f , 1.0f, 1.0f, 0.5f+(*pFade/Seconds)*0.25f), Corners, 12.0f);
|
||||
|
||||
RenderTools()->DrawUIRect(pRect, vec4(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f+FadeVal*0.5f), Corners, r);
|
||||
CUIRect Temp;
|
||||
pRect->HMargin(2.0f, &Temp);
|
||||
pRect->HMargin(pRect->h>=20.0f?2.0f:1.0f, &Temp);
|
||||
Temp.HMargin((Temp.h*FontFactor)/2.0f, &Temp);
|
||||
TextRender()->TextColor(1.0f-FadeVal, 1.0f-FadeVal, 1.0f-FadeVal, 1.0f);
|
||||
TextRender()->TextOutlineColor(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f);
|
||||
UI()->DoLabel(&Temp, pText, Temp.h*ms_FontmodHeight, 0);
|
||||
|
||||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
|
||||
return UI()->DoButtonLogic(pID, pText, Checked, pRect);
|
||||
}
|
||||
|
||||
|
@ -249,9 +266,11 @@ int CMenus::DoButton_GridHeaderIcon(const void *pID, int ImageID, int SpriteID,
|
|||
return UI()->DoButtonLogic(pID, "", false, pRect);
|
||||
}
|
||||
|
||||
int CMenus::DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect)
|
||||
int CMenus::DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect, bool Checked)
|
||||
//void CMenus::ui_draw_checkbox_common(const void *id, const char *text, const char *boxtext, const CUIRect *r, const void *extra)
|
||||
{
|
||||
RenderTools()->DrawUIRect(pRect, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
|
||||
|
||||
CUIRect c = *pRect;
|
||||
CUIRect t = *pRect;
|
||||
c.w = c.h;
|
||||
|
@ -259,12 +278,19 @@ int CMenus::DoButton_CheckBox_Common(const void *pID, const char *pText, const c
|
|||
t.w -= c.w;
|
||||
t.VSplitLeft(5.0f, 0, &t);
|
||||
|
||||
float Seconds = 0.6f; // 0.6 seconds for fade
|
||||
float *pFade = ButtonFade(pID, Seconds);
|
||||
|
||||
c.Margin(2.0f, &c);
|
||||
RenderTools()->DrawUIRect(&c, vec4(1.0f , 1.0f, 1.0f, 0.25f+(*pFade/Seconds)*0.125f), CUI::CORNER_ALL, 3.0f);
|
||||
c.y += 2;
|
||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CHECKBOXICONS].m_Id);
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, UI()->HotItem() == pID ? 1.0f : 0.6f);
|
||||
if(Checked)
|
||||
RenderTools()->SelectSprite(SPRITE_CHECKBOX_ACTIVE);
|
||||
else
|
||||
RenderTools()->SelectSprite(SPRITE_CHECKBOX_INACTIVE);
|
||||
IGraphics::CQuadItem QuadItem(c.x, c.y, c.w, c.h);
|
||||
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
||||
Graphics()->QuadsEnd();
|
||||
|
||||
t.y += 2.0f; // lame fix
|
||||
UI()->DoLabel(&c, pBoxText, pRect->h*ms_FontmodHeight*0.6f, 0);
|
||||
UI()->DoLabel(&t, pText, pRect->h*ms_FontmodHeight*0.8f, -1);
|
||||
return UI()->DoButtonLogic(pID, pText, 0, pRect);
|
||||
|
@ -272,10 +298,9 @@ int CMenus::DoButton_CheckBox_Common(const void *pID, const char *pText, const c
|
|||
|
||||
int CMenus::DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect)
|
||||
{
|
||||
return DoButton_CheckBox_Common(pID, pText, Checked?"X":"", pRect);
|
||||
return DoButton_CheckBox_Common(pID, pText, "", pRect, Checked);
|
||||
}
|
||||
|
||||
|
||||
int CMenus::DoButton_CheckBox_Number(const void *pID, const char *pText, int Checked, const CUIRect *pRect)
|
||||
{
|
||||
char aBuf[16];
|
||||
|
@ -332,7 +357,7 @@ int CMenus::DoButton_MouseOver(int ImageID, int SpriteID, const CUIRect *pRect)
|
|||
return Inside;
|
||||
}
|
||||
|
||||
int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden, int Corners)
|
||||
int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden, int Corners)
|
||||
{
|
||||
int Inside = UI()->MouseInside(pRect);
|
||||
bool ReturnValue = false;
|
||||
|
@ -354,10 +379,11 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS
|
|||
s_DoScroll = true;
|
||||
s_ScrollStart = UI()->MouseX();
|
||||
int MxRel = (int)(UI()->MouseX() - pRect->x);
|
||||
float Offset = pRect->w/2.0f-TextRender()->TextWidth(0, FontSize, pStr, -1)/2.0f;
|
||||
|
||||
for(int i = 1; i <= Len; i++)
|
||||
{
|
||||
if(TextRender()->TextWidth(0, FontSize, pStr, i) - *Offset > MxRel)
|
||||
if(Offset + TextRender()->TextWidth(0, FontSize, pStr, i) - *pOffset > MxRel)
|
||||
{
|
||||
s_AtIndex = i - 1;
|
||||
break;
|
||||
|
@ -418,7 +444,7 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS
|
|||
UI()->SetHotItem(pID);
|
||||
|
||||
CUIRect Textbox = *pRect;
|
||||
RenderTools()->DrawUIRect(&Textbox, vec4(1, 1, 1, 0.5f), Corners, 3.0f);
|
||||
RenderTools()->DrawUIRect(&Textbox, vec4(0.0f, 0.0f, 0.0f, 0.25f), Corners, 5.0f);
|
||||
Textbox.VMargin(2.0f, &Textbox);
|
||||
Textbox.HMargin(2.0f, &Textbox);
|
||||
|
||||
|
@ -440,38 +466,39 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS
|
|||
if(UI()->LastActiveItem() == pID && !JustGotActive && (UpdateOffset || m_NumInputEvents))
|
||||
{
|
||||
float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, s_AtIndex);
|
||||
if(w-*Offset > Textbox.w)
|
||||
if(w-*pOffset > Textbox.w)
|
||||
{
|
||||
// move to the left
|
||||
float wt = TextRender()->TextWidth(0, FontSize, pDisplayStr, -1);
|
||||
do
|
||||
{
|
||||
*Offset += min(wt-*Offset-Textbox.w, Textbox.w/3);
|
||||
*pOffset += min(wt-*pOffset-Textbox.w, Textbox.w/3);
|
||||
}
|
||||
while(w-*Offset > Textbox.w);
|
||||
while(w-*pOffset > Textbox.w);
|
||||
}
|
||||
else if(w-*Offset < 0.0f)
|
||||
else if(w-*pOffset < 0.0f)
|
||||
{
|
||||
// move to the right
|
||||
do
|
||||
{
|
||||
*Offset = max(0.0f, *Offset-Textbox.w/3);
|
||||
*pOffset = max(0.0f, *pOffset-Textbox.w/3);
|
||||
}
|
||||
while(w-*Offset < 0.0f);
|
||||
while(w-*pOffset < 0.0f);
|
||||
}
|
||||
}
|
||||
UI()->ClipEnable(pRect);
|
||||
Textbox.x -= *Offset;
|
||||
Textbox.x -= *pOffset;
|
||||
|
||||
UI()->DoLabel(&Textbox, pDisplayStr, FontSize, -1);
|
||||
UI()->DoLabel(&Textbox, pDisplayStr, FontSize, 0);
|
||||
|
||||
// render the cursor
|
||||
if(UI()->LastActiveItem() == pID && !JustGotActive)
|
||||
{
|
||||
float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, s_AtIndex);
|
||||
float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, -1);
|
||||
Textbox = *pRect;
|
||||
Textbox.VSplitLeft(2.0f, 0, &Textbox);
|
||||
Textbox.x += (w-*Offset-TextRender()->TextWidth(0, FontSize, "|", -1)/2);
|
||||
Textbox.x += Textbox.w/2.0f-w/2.0f;
|
||||
w = TextRender()->TextWidth(0, FontSize, pDisplayStr, s_AtIndex);
|
||||
Textbox.x += (w-*pOffset-TextRender()->TextWidth(0, FontSize, "|", -1)/2);
|
||||
|
||||
if((2*time_get()/time_freq()) % 2) // make it blink
|
||||
UI()->DoLabel(&Textbox, "|", FontSize, -1);
|
||||
|
@ -481,6 +508,108 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS
|
|||
return ReturnValue;
|
||||
}
|
||||
|
||||
void CMenus::DoEditBoxOption(void *pID, char *pOption, int OptionLength, const CUIRect *pRect, const char *pStr, float VSplitVal, float *pOffset)
|
||||
{
|
||||
RenderTools()->DrawUIRect(pRect, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
|
||||
|
||||
CUIRect Label, EditBox;
|
||||
pRect->VSplitLeft(VSplitVal, &Label, &EditBox);
|
||||
|
||||
char aBuf[32];
|
||||
str_format(aBuf, sizeof(aBuf), "%s:", pStr);
|
||||
Label.y += 2.0f;
|
||||
UI()->DoLabel(&Label, aBuf, pRect->h*ms_FontmodHeight*0.8f, 0);
|
||||
|
||||
DoEditBox(pID, &EditBox, pOption, OptionLength, pRect->h*ms_FontmodHeight*0.8f, pOffset);
|
||||
}
|
||||
|
||||
void CMenus::DoScrollbarOption(void *pID, int *pOption, const CUIRect *pRect, const char *pStr, float VSplitVal, int Min, int Max, bool infinite)
|
||||
{
|
||||
RenderTools()->DrawUIRect(pRect, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
|
||||
|
||||
CUIRect Label, ScrollBar;
|
||||
pRect->VSplitLeft(VSplitVal, &Label, &ScrollBar);
|
||||
|
||||
char aBuf[32];
|
||||
if(*pOption || !infinite)
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %i", pStr, *pOption);
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "%s: \xe2\x88\x9e", pStr);
|
||||
Label.VSplitLeft(Label.h+5.0f, 0, &Label);
|
||||
Label.y += 2.0f;
|
||||
UI()->DoLabel(&Label, aBuf, pRect->h*ms_FontmodHeight*0.8f, -1);
|
||||
|
||||
ScrollBar.VMargin(4.0f, &ScrollBar);
|
||||
*pOption = static_cast<int>(DoScrollbarH(pOption, &ScrollBar, (float)(*pOption-Min)/(float)(Max-Min))*(float)(Max-Min)+(float)Min+0.1f);
|
||||
}
|
||||
|
||||
float CMenus::DoDropdownMenu(void *pID, const CUIRect *pRect, const char *pStr, float HeaderHeight, FDropdownCallback pfnCallback)
|
||||
{
|
||||
CUIRect View = *pRect;
|
||||
CUIRect Header, Label;
|
||||
|
||||
bool Active = pID == m_pActiveDropdown;
|
||||
int Corners = Active ? CUI::CORNER_T : CUI::CORNER_ALL;
|
||||
|
||||
View.HSplitTop(HeaderHeight, &Header, &View);
|
||||
|
||||
// background
|
||||
RenderTools()->DrawUIRect(&Header, vec4(0.0f, 0.0f, 0.0f, 0.25f), Corners, 5.0f);
|
||||
|
||||
// render icon
|
||||
CUIRect Button;
|
||||
Header.VSplitLeft(Header.h, &Button, 0);
|
||||
Button.Margin(2.0f, &Button);
|
||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_FOLDICONS].m_Id);
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, UI()->HotItem() == pID ? 1.0f : 0.6f);
|
||||
if(Active)
|
||||
RenderTools()->SelectSprite(SPRITE_FOLD_EXPANDED);
|
||||
else
|
||||
RenderTools()->SelectSprite(SPRITE_FOLD_COLLAPSED);
|
||||
IGraphics::CQuadItem QuadItem(Button.x, Button.y, Button.w, Button.h);
|
||||
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
|
||||
// label
|
||||
Label = Header;
|
||||
Label.y += 2.0f;
|
||||
UI()->DoLabel(&Label, pStr, Header.h*ms_FontmodHeight*0.8f, 0);
|
||||
|
||||
if(UI()->DoButtonLogic(pID, 0, 0, &Header))
|
||||
{
|
||||
if(Active)
|
||||
m_pActiveDropdown = 0;
|
||||
else
|
||||
m_pActiveDropdown = (int*)pID;
|
||||
}
|
||||
|
||||
// render content of expanded menu
|
||||
if(Active)
|
||||
return HeaderHeight + pfnCallback(View, this);
|
||||
|
||||
return HeaderHeight;
|
||||
}
|
||||
|
||||
void CMenus::DoInfoBox(const CUIRect *pRect, const char *pLabel, const char *pValue)
|
||||
{
|
||||
RenderTools()->DrawUIRect(pRect, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
|
||||
|
||||
CUIRect Label, Value;
|
||||
pRect->VSplitMid(&Label, &Value);
|
||||
|
||||
RenderTools()->DrawUIRect(&Value, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
|
||||
|
||||
char aBuf[32];
|
||||
str_format(aBuf, sizeof(aBuf), "%s:", pLabel);
|
||||
Label.y += 2.0f;
|
||||
UI()->DoLabel(&Label, aBuf, pRect->h*ms_FontmodHeight*0.8f, 0);
|
||||
|
||||
Value.y += 2.0f;
|
||||
UI()->DoLabel(&Value, pValue, pRect->h*ms_FontmodHeight*0.8f, 0);
|
||||
}
|
||||
|
||||
float CMenus::DoScrollbarV(const void *pID, const CUIRect *pRect, float Current)
|
||||
{
|
||||
CUIRect Handle;
|
||||
|
@ -520,27 +649,16 @@ float CMenus::DoScrollbarV(const void *pID, const CUIRect *pRect, float Current)
|
|||
// render
|
||||
CUIRect Rail;
|
||||
pRect->VMargin(5.0f, &Rail);
|
||||
RenderTools()->DrawUIRect(&Rail, vec4(1,1,1,0.25f), 0, 0.0f);
|
||||
RenderTools()->DrawUIRect(&Rail, vec4(1.0f, 1.0f, 1.0f, 0.25f), CUI::CORNER_ALL, Rail.w/2.0f);
|
||||
|
||||
CUIRect Slider = Handle;
|
||||
Slider.w = Rail.x-Slider.x;
|
||||
RenderTools()->DrawUIRect(&Slider, vec4(1,1,1,0.25f), CUI::CORNER_L, 2.5f);
|
||||
Slider.x = Rail.x+Rail.w;
|
||||
RenderTools()->DrawUIRect(&Slider, vec4(1,1,1,0.25f), CUI::CORNER_R, 2.5f);
|
||||
Slider.VMargin(5.0f, &Slider);
|
||||
|
||||
Slider = Handle;
|
||||
Slider.Margin(5.0f, &Slider);
|
||||
|
||||
float Seconds = 0.6f; // 0.6 seconds for fade
|
||||
float *pFade = ButtonFade(pID, Seconds);
|
||||
|
||||
RenderTools()->DrawUIRect(&Slider, vec4(1.0f , 1.0f, 1.0f, 0.25f+(*pFade/Seconds)*0.125f), CUI::CORNER_ALL, 2.5f);
|
||||
RenderTools()->DrawUIRect(&Slider, vec4(1.0f , 1.0f, 1.0f, 1.0f), CUI::CORNER_ALL, Slider.w/2.0f);
|
||||
|
||||
return ReturnValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float CMenus::DoScrollbarH(const void *pID, const CUIRect *pRect, float Current)
|
||||
{
|
||||
CUIRect Handle;
|
||||
|
@ -580,25 +698,244 @@ float CMenus::DoScrollbarH(const void *pID, const CUIRect *pRect, float Current)
|
|||
// render
|
||||
CUIRect Rail;
|
||||
pRect->HMargin(5.0f, &Rail);
|
||||
RenderTools()->DrawUIRect(&Rail, vec4(1,1,1,0.25f), 0, 0.0f);
|
||||
RenderTools()->DrawUIRect(&Rail, vec4(1.0f, 1.0f, 1.0f, 0.25f), CUI::CORNER_ALL, Rail.h/2.0f);
|
||||
|
||||
CUIRect Slider = Handle;
|
||||
Slider.h = Rail.y-Slider.y;
|
||||
RenderTools()->DrawUIRect(&Slider, vec4(1,1,1,0.25f), CUI::CORNER_T, 2.5f);
|
||||
Slider.y = Rail.y+Rail.h;
|
||||
RenderTools()->DrawUIRect(&Slider, vec4(1,1,1,0.25f), CUI::CORNER_B, 2.5f);
|
||||
Slider.HMargin(5.0f, &Slider);
|
||||
|
||||
Slider = Handle;
|
||||
Slider.Margin(5.0f, &Slider);
|
||||
|
||||
float Seconds = 0.6f; // 0.6 seconds for fade
|
||||
float *pFade = ButtonFade(pID, Seconds);
|
||||
|
||||
RenderTools()->DrawUIRect(&Slider, vec4(1.0f , 1.0f, 1.0f, 0.25f+(*pFade/Seconds)*0.125f), CUI::CORNER_ALL, 2.5f);
|
||||
RenderTools()->DrawUIRect(&Slider, vec4(1.0f , 1.0f, 1.0f, 1.0f), CUI::CORNER_ALL, Slider.h/2.0f);
|
||||
|
||||
return ReturnValue;
|
||||
}
|
||||
|
||||
static CUIRect gs_ListBoxOriginalView;
|
||||
static CUIRect gs_ListBoxView;
|
||||
static float gs_ListBoxRowHeight;
|
||||
static int gs_ListBoxItemIndex;
|
||||
static int gs_ListBoxSelectedIndex;
|
||||
static int gs_ListBoxNewSelected;
|
||||
static int gs_ListBoxDoneEvents;
|
||||
static int gs_ListBoxNumItems;
|
||||
static int gs_ListBoxItemsPerRow;
|
||||
static float gs_ListBoxScrollValue;
|
||||
static bool gs_ListBoxItemActivated;
|
||||
|
||||
void CMenus::UiDoListboxHeader(const CUIRect *pRect, const char *pTitle, float HeaderHeight, float Spaceing)
|
||||
{
|
||||
CUIRect Header;
|
||||
CUIRect View = *pRect;
|
||||
|
||||
// background
|
||||
View.HSplitTop(ms_ListheaderHeight+Spaceing, &Header, 0);
|
||||
RenderTools()->DrawUIRect(&Header, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_T, 5.0f);
|
||||
|
||||
// draw header
|
||||
View.HSplitTop(ms_ListheaderHeight, &Header, &View);
|
||||
Header.y += 2.0f;
|
||||
UI()->DoLabel(&Header, pTitle, Header.h*ms_FontmodHeight*0.8f, 0);
|
||||
|
||||
View.HSplitTop(Spaceing, &Header, &View);
|
||||
|
||||
// setup the variables
|
||||
gs_ListBoxOriginalView = View;
|
||||
}
|
||||
|
||||
void CMenus::UiDoListboxStart(const void *pID, float RowHeight, const char *pBottomText, int NumItems,
|
||||
int ItemsPerRow, int SelectedIndex, float ScrollValue, const CUIRect *pRect)
|
||||
{
|
||||
CUIRect View, Scroll, Row;
|
||||
if(pRect)
|
||||
View = *pRect;
|
||||
else
|
||||
View = gs_ListBoxOriginalView;
|
||||
CUIRect Header, Footer;
|
||||
|
||||
// background
|
||||
RenderTools()->DrawUIRect(&View, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_B, 5.0f);
|
||||
|
||||
// draw footers
|
||||
if(pBottomText)
|
||||
{
|
||||
View.HSplitBottom(ms_ListheaderHeight, &View, &Footer);
|
||||
Footer.VSplitLeft(10.0f, 0, &Footer);
|
||||
Footer.y += 2.0f;
|
||||
UI()->DoLabel(&Footer, pBottomText, Footer.h*ms_FontmodHeight*0.8f, 0);
|
||||
}
|
||||
|
||||
// list background
|
||||
RenderTools()->DrawUIRect(&View, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
|
||||
|
||||
// prepare the scroll
|
||||
View.VSplitRight(20.0f, &View, &Scroll);
|
||||
|
||||
// setup the variables
|
||||
gs_ListBoxOriginalView = View;
|
||||
gs_ListBoxSelectedIndex = SelectedIndex;
|
||||
gs_ListBoxNewSelected = SelectedIndex;
|
||||
gs_ListBoxItemIndex = 0;
|
||||
gs_ListBoxRowHeight = RowHeight;
|
||||
gs_ListBoxNumItems = NumItems;
|
||||
gs_ListBoxItemsPerRow = ItemsPerRow;
|
||||
gs_ListBoxDoneEvents = 0;
|
||||
gs_ListBoxScrollValue = ScrollValue;
|
||||
gs_ListBoxItemActivated = false;
|
||||
|
||||
// do the scrollbar
|
||||
View.HSplitTop(gs_ListBoxRowHeight, &Row, 0);
|
||||
|
||||
int NumViewable = (int)(gs_ListBoxOriginalView.h/Row.h) + 1;
|
||||
int Num = (NumItems+gs_ListBoxItemsPerRow-1)/gs_ListBoxItemsPerRow-NumViewable+1;
|
||||
if(Num < 0)
|
||||
Num = 0;
|
||||
if(Num > 0)
|
||||
{
|
||||
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_UP) && UI()->MouseInside(&View))
|
||||
gs_ListBoxScrollValue -= 3.0f/Num;
|
||||
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN) && UI()->MouseInside(&View))
|
||||
gs_ListBoxScrollValue += 3.0f/Num;
|
||||
|
||||
if(gs_ListBoxScrollValue < 0.0f) gs_ListBoxScrollValue = 0.0f;
|
||||
if(gs_ListBoxScrollValue > 1.0f) gs_ListBoxScrollValue = 1.0f;
|
||||
}
|
||||
|
||||
Scroll.HMargin(5.0f, &Scroll);
|
||||
gs_ListBoxScrollValue = DoScrollbarV(pID, &Scroll, gs_ListBoxScrollValue);
|
||||
|
||||
// the list
|
||||
gs_ListBoxView = gs_ListBoxOriginalView;
|
||||
gs_ListBoxView.VMargin(5.0f, &gs_ListBoxView);
|
||||
UI()->ClipEnable(&gs_ListBoxView);
|
||||
gs_ListBoxView.y -= gs_ListBoxScrollValue*Num*Row.h;
|
||||
}
|
||||
|
||||
CMenus::CListboxItem CMenus::UiDoListboxNextRow()
|
||||
{
|
||||
static CUIRect s_RowView;
|
||||
CListboxItem Item = {0};
|
||||
if(gs_ListBoxItemIndex%gs_ListBoxItemsPerRow == 0)
|
||||
gs_ListBoxView.HSplitTop(gs_ListBoxRowHeight /*-2.0f*/, &s_RowView, &gs_ListBoxView);
|
||||
|
||||
s_RowView.VSplitLeft(s_RowView.w/(gs_ListBoxItemsPerRow-gs_ListBoxItemIndex%gs_ListBoxItemsPerRow)/(UI()->Scale()), &Item.m_Rect, &s_RowView);
|
||||
|
||||
Item.m_Visible = 1;
|
||||
//item.rect = row;
|
||||
|
||||
Item.m_HitRect = Item.m_Rect;
|
||||
|
||||
//CUIRect select_hit_box = item.rect;
|
||||
|
||||
if(gs_ListBoxSelectedIndex == gs_ListBoxItemIndex)
|
||||
Item.m_Selected = 1;
|
||||
|
||||
// make sure that only those in view can be selected
|
||||
if(Item.m_Rect.y+Item.m_Rect.h > gs_ListBoxOriginalView.y)
|
||||
{
|
||||
|
||||
if(Item.m_HitRect.y < Item.m_HitRect.y) // clip the selection
|
||||
{
|
||||
Item.m_HitRect.h -= gs_ListBoxOriginalView.y-Item.m_HitRect.y;
|
||||
Item.m_HitRect.y = gs_ListBoxOriginalView.y;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
Item.m_Visible = 0;
|
||||
|
||||
// check if we need to do more
|
||||
if(Item.m_Rect.y > gs_ListBoxOriginalView.y+gs_ListBoxOriginalView.h)
|
||||
Item.m_Visible = 0;
|
||||
|
||||
gs_ListBoxItemIndex++;
|
||||
return Item;
|
||||
}
|
||||
|
||||
CMenus::CListboxItem CMenus::UiDoListboxNextItem(const void *pId, bool Selected)
|
||||
{
|
||||
int ThisItemIndex = gs_ListBoxItemIndex;
|
||||
if(Selected)
|
||||
{
|
||||
if(gs_ListBoxSelectedIndex == gs_ListBoxNewSelected)
|
||||
gs_ListBoxNewSelected = ThisItemIndex;
|
||||
gs_ListBoxSelectedIndex = ThisItemIndex;
|
||||
}
|
||||
|
||||
CListboxItem Item = UiDoListboxNextRow();
|
||||
|
||||
if(Item.m_Visible && UI()->DoButtonLogic(pId, "", gs_ListBoxSelectedIndex == gs_ListBoxItemIndex, &Item.m_HitRect))
|
||||
gs_ListBoxNewSelected = ThisItemIndex;
|
||||
|
||||
// process input, regard selected index
|
||||
if(gs_ListBoxSelectedIndex == ThisItemIndex)
|
||||
{
|
||||
if(!gs_ListBoxDoneEvents)
|
||||
{
|
||||
gs_ListBoxDoneEvents = 1;
|
||||
|
||||
if(m_EnterPressed || (UI()->ActiveItem() == pId && Input()->MouseDoubleClick()))
|
||||
{
|
||||
gs_ListBoxItemActivated = true;
|
||||
UI()->SetActiveItem(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < m_NumInputEvents; i++)
|
||||
{
|
||||
int NewIndex = -1;
|
||||
if(m_aInputEvents[i].m_Flags&IInput::FLAG_PRESS)
|
||||
{
|
||||
if(m_aInputEvents[i].m_Key == KEY_DOWN) NewIndex = gs_ListBoxNewSelected + 1;
|
||||
if(m_aInputEvents[i].m_Key == KEY_UP) NewIndex = gs_ListBoxNewSelected - 1;
|
||||
}
|
||||
if(NewIndex > -1 && NewIndex < gs_ListBoxNumItems)
|
||||
{
|
||||
// scroll
|
||||
float Offset = (NewIndex/gs_ListBoxItemsPerRow-gs_ListBoxNewSelected/gs_ListBoxItemsPerRow)*gs_ListBoxRowHeight;
|
||||
int Scroll = gs_ListBoxOriginalView.y > Item.m_Rect.y+Offset ? -1 :
|
||||
gs_ListBoxOriginalView.y+gs_ListBoxOriginalView.h < Item.m_Rect.y+Item.m_Rect.h+Offset ? 1 : 0;
|
||||
if(Scroll)
|
||||
{
|
||||
int NumViewable = (int)(gs_ListBoxOriginalView.h/gs_ListBoxRowHeight) + 1;
|
||||
int ScrollNum = (gs_ListBoxNumItems+gs_ListBoxItemsPerRow-1)/gs_ListBoxItemsPerRow-NumViewable+1;
|
||||
if(Scroll < 0)
|
||||
{
|
||||
int Num = (gs_ListBoxOriginalView.y-Item.m_Rect.y-Offset+gs_ListBoxRowHeight-1.0f)/gs_ListBoxRowHeight;
|
||||
gs_ListBoxScrollValue -= (1.0f/ScrollNum)*Num;
|
||||
}
|
||||
else
|
||||
{
|
||||
int Num = (Item.m_Rect.y+Item.m_Rect.h+Offset-(gs_ListBoxOriginalView.y+gs_ListBoxOriginalView.h)+gs_ListBoxRowHeight-1.0f)/
|
||||
gs_ListBoxRowHeight;
|
||||
gs_ListBoxScrollValue += (1.0f/ScrollNum)*Num;
|
||||
}
|
||||
if(gs_ListBoxScrollValue < 0.0f) gs_ListBoxScrollValue = 0.0f;
|
||||
if(gs_ListBoxScrollValue > 1.0f) gs_ListBoxScrollValue = 1.0f;
|
||||
}
|
||||
|
||||
gs_ListBoxNewSelected = NewIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//selected_index = i;
|
||||
CUIRect r = Item.m_Rect;
|
||||
r.Margin(1.5f, &r);
|
||||
RenderTools()->DrawUIRect(&r, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 5.0f);
|
||||
}
|
||||
|
||||
return Item;
|
||||
}
|
||||
|
||||
int CMenus::UiDoListboxEnd(float *pScrollValue, bool *pItemActivated)
|
||||
{
|
||||
UI()->ClipDisable();
|
||||
if(pScrollValue)
|
||||
*pScrollValue = gs_ListBoxScrollValue;
|
||||
if(pItemActivated)
|
||||
*pItemActivated = gs_ListBoxItemActivated;
|
||||
return gs_ListBoxNewSelected;
|
||||
}
|
||||
|
||||
int CMenus::DoKeyReader(void *pID, const CUIRect *pRect, int Key)
|
||||
{
|
||||
// process
|
||||
|
@ -667,8 +1004,7 @@ int CMenus::DoKeyReader(void *pID, const CUIRect *pRect, int Key)
|
|||
return NewKey;
|
||||
}
|
||||
|
||||
|
||||
int CMenus::RenderMenubar(CUIRect r)
|
||||
void CMenus::RenderMenubar(CUIRect r)
|
||||
{
|
||||
CUIRect Box = r;
|
||||
CUIRect Button;
|
||||
|
@ -681,54 +1017,10 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
|
||||
if(Client()->State() == IClient::STATE_OFFLINE)
|
||||
{
|
||||
/*/ offline menus
|
||||
if(0) // this is not done yet
|
||||
{
|
||||
Box.VSplitLeft(90.0f, &Button, &Box);
|
||||
static int s_NewsButton=0;
|
||||
if (DoButton_MenuTab(&s_NewsButton, Localize("News"), m_ActivePage==PAGE_NEWS, &Button, 0))
|
||||
NewPage = PAGE_NEWS;
|
||||
Box.VSplitLeft(30.0f, 0, &Box);
|
||||
}
|
||||
// render header background
|
||||
RenderTools()->DrawUIRect4(&Box, vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.25f), vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_B, 5.0f);
|
||||
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
static int s_InternetButton=0;
|
||||
if(DoButton_MenuTab(&s_InternetButton, Localize("Internet"), m_ActivePage==PAGE_INTERNET, &Button, CUI::CORNER_TL|CUI::CORNER_IBL) && m_ActivePage!=PAGE_INTERNET)
|
||||
{
|
||||
m_pClient->m_pCamera->ChangePosition(CCamera::POS_INTERNET);
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
|
||||
NewPage = PAGE_INTERNET;
|
||||
}
|
||||
|
||||
//Box.VSplitLeft(4.0f, 0, &Box);
|
||||
Box.VSplitLeft(80.0f, &Button, &Box);
|
||||
static int s_LanButton=0;
|
||||
if(DoButton_MenuTab(&s_LanButton, Localize("LAN"), m_ActivePage==PAGE_LAN, &Button, 0) && m_ActivePage!=PAGE_LAN)
|
||||
{
|
||||
m_pClient->m_pCamera->ChangePosition(CCamera::POS_LAN);
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN);
|
||||
NewPage = PAGE_LAN;
|
||||
}
|
||||
|
||||
//box.VSplitLeft(4.0f, 0, &box);
|
||||
Box.VSplitLeft(110.0f, &Button, &Box);
|
||||
static int s_FavoritesButton=0;
|
||||
if(DoButton_MenuTab(&s_FavoritesButton, Localize("Favorites"), m_ActivePage==PAGE_FAVORITES, &Button, CUI::CORNER_TR) && m_ActivePage!=PAGE_FAVORITES)
|
||||
{
|
||||
m_pClient->m_pCamera->ChangePosition(CCamera::POS_FAVORITES);
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
|
||||
NewPage = PAGE_FAVORITES;
|
||||
}
|
||||
|
||||
Box.VSplitLeft(4.0f*5, 0, &Box);
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
static int s_DemosButton=0;
|
||||
if(DoButton_MenuTab(&s_DemosButton, Localize("Demos"), m_ActivePage==PAGE_DEMOS, &Button, CUI::CORNER_T) && m_ActivePage!=PAGE_DEMOS)
|
||||
{
|
||||
m_pClient->m_pCamera->ChangePosition(CCamera::POS_DEMOS);
|
||||
DemolistPopulate();
|
||||
NewPage = PAGE_DEMOS;
|
||||
}*/
|
||||
Box.HSplitBottom(25.0f, 0, &Box);
|
||||
|
||||
// render menu tabs
|
||||
if(m_MenuPage >= PAGE_INTERNET && m_MenuPage <= PAGE_FRIENDS)
|
||||
|
@ -756,54 +1048,67 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
}
|
||||
else if(m_MenuPage == PAGE_SETTINGS)
|
||||
{
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
float Spacing = 3.0f;
|
||||
float ButtonWidth = (Box.w/6.0f)-(Spacing*5.0)/6.0f;
|
||||
|
||||
Box.VSplitLeft(ButtonWidth, &Button, &Box);
|
||||
static int s_GeneralButton=0;
|
||||
if(DoButton_MenuTabTop(&s_GeneralButton, Localize("General"), g_Config.m_UiSettingsPage==SETTINGS_GENERAL, &Button, CUI::CORNER_T|CUI::CORNER_IBL))
|
||||
if(DoButton_MenuTabTop(&s_GeneralButton, Localize("General"), g_Config.m_UiSettingsPage==SETTINGS_GENERAL, &Button))
|
||||
{
|
||||
g_Config.m_UiSettingsPage = SETTINGS_GENERAL;
|
||||
}
|
||||
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
Box.VSplitLeft(Spacing, 0, &Box); // little space
|
||||
Box.VSplitLeft(ButtonWidth, &Button, &Box);
|
||||
static int s_PlayerButton=0;
|
||||
if(DoButton_MenuTabTop(&s_PlayerButton, Localize("Player"), g_Config.m_UiSettingsPage==SETTINGS_PLAYER, &Button, CUI::CORNER_T))
|
||||
if(DoButton_MenuTabTop(&s_PlayerButton, Localize("Player"), g_Config.m_UiSettingsPage==SETTINGS_PLAYER, &Button))
|
||||
{
|
||||
g_Config.m_UiSettingsPage = SETTINGS_PLAYER;
|
||||
}
|
||||
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
Box.VSplitLeft(Spacing, 0, &Box); // little space
|
||||
Box.VSplitLeft(ButtonWidth, &Button, &Box);
|
||||
static int s_TeeButton=0;
|
||||
if(DoButton_MenuTabTop(&s_TeeButton, Localize("Tee"), g_Config.m_UiSettingsPage==SETTINGS_TEE, &Button, CUI::CORNER_T))
|
||||
if(DoButton_MenuTabTop(&s_TeeButton, Localize("Tee"), g_Config.m_UiSettingsPage==SETTINGS_TEE, &Button))
|
||||
{
|
||||
g_Config.m_UiSettingsPage = SETTINGS_TEE;
|
||||
}
|
||||
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
Box.VSplitLeft(Spacing, 0, &Box); // little space
|
||||
Box.VSplitLeft(ButtonWidth, &Button, &Box);
|
||||
static int s_ControlsButton=0;
|
||||
if(DoButton_MenuTabTop(&s_ControlsButton, Localize("Controls"), g_Config.m_UiSettingsPage==SETTINGS_CONTROLS, &Button, CUI::CORNER_T))
|
||||
if(DoButton_MenuTabTop(&s_ControlsButton, Localize("Controls"), g_Config.m_UiSettingsPage==SETTINGS_CONTROLS, &Button))
|
||||
{
|
||||
g_Config.m_UiSettingsPage = SETTINGS_CONTROLS;
|
||||
}
|
||||
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
Box.VSplitLeft(Spacing, 0, &Box); // little space
|
||||
Box.VSplitLeft(ButtonWidth, &Button, &Box);
|
||||
static int s_GraphicsButton=0;
|
||||
if(DoButton_MenuTabTop(&s_GraphicsButton, Localize("Graphics"), g_Config.m_UiSettingsPage==SETTINGS_GRAPHICS, &Button, CUI::CORNER_T))
|
||||
if(DoButton_MenuTabTop(&s_GraphicsButton, Localize("Graphics"), g_Config.m_UiSettingsPage==SETTINGS_GRAPHICS, &Button))
|
||||
{
|
||||
g_Config.m_UiSettingsPage = SETTINGS_GRAPHICS;
|
||||
}
|
||||
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
Box.VSplitLeft(Spacing, 0, &Box); // little space
|
||||
Box.VSplitLeft(ButtonWidth, &Button, &Box);
|
||||
static int s_SoundButton=0;
|
||||
if(DoButton_MenuTabTop(&s_SoundButton, Localize("Sound"), g_Config.m_UiSettingsPage==SETTINGS_SOUND, &Button, CUI::CORNER_T))
|
||||
if(DoButton_MenuTabTop(&s_SoundButton, Localize("Sound"), g_Config.m_UiSettingsPage==SETTINGS_SOUND, &Button))
|
||||
{
|
||||
g_Config.m_UiSettingsPage = SETTINGS_SOUND;
|
||||
}
|
||||
}
|
||||
|
||||
// back to menu
|
||||
Box.VSplitRight(90.0f, &Box, &Button);
|
||||
static int s_MenuButton=0;
|
||||
if(DoButton_Menu(&s_MenuButton, Localize("Menu"), 0, &Button, 12.0f, 0.0f, CUI::CORNER_T|CUI::CORNER_IBR))
|
||||
NewPage = PAGE_START;
|
||||
else if(m_MenuPage == PAGE_DEMOS)
|
||||
{
|
||||
// make the header look like an active tab
|
||||
RenderTools()->DrawUIRect(&Box, vec4(1.0f, 1.0f, 1.0f, 0.75f), CUI::CORNER_ALL, 5.0f);
|
||||
Box.HMargin(2.0f, &Box);
|
||||
TextRender()->TextColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
TextRender()->TextOutlineColor(1.0f, 1.0f, 1.0f, 0.25f);
|
||||
UI()->DoLabel(&Box, Localize("Demo"), Box.h*ms_FontmodHeight, 0);
|
||||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -886,8 +1191,6 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
else
|
||||
m_GamePage = NewPage;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CMenus::RenderLoading()
|
||||
|
@ -1039,8 +1342,83 @@ const CMenus::CMenuImage *CMenus::FindMenuImage(const char *pName)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void CMenus::UpdateVideoFormats()
|
||||
{
|
||||
m_NumVideoFormats = 0;
|
||||
for(int i = 0; i < m_NumModes; i++)
|
||||
{
|
||||
int G = gcd(m_aModes[i].m_Width, m_aModes[i].m_Height);
|
||||
int Width = m_aModes[i].m_Width/G;
|
||||
int Height = m_aModes[i].m_Height/G;
|
||||
|
||||
// check if we already have the format
|
||||
bool Found = false;
|
||||
for(int j = 0; j < m_NumVideoFormats; j++)
|
||||
{
|
||||
if(Width == m_aVideoFormats[j].m_WidthValue && Height == m_aVideoFormats[j].m_HeightValue)
|
||||
{
|
||||
Found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!Found)
|
||||
{
|
||||
m_aVideoFormats[m_NumVideoFormats].m_WidthValue = Width;
|
||||
m_aVideoFormats[m_NumVideoFormats].m_HeightValue = Height;
|
||||
m_NumVideoFormats++;
|
||||
|
||||
// sort the array
|
||||
for(int k = 0; k < m_NumVideoFormats-1; k++) // ffs, bubblesort
|
||||
{
|
||||
for(int j = 0; j < m_NumVideoFormats-k-1; j++)
|
||||
{
|
||||
if((float)m_aVideoFormats[j].m_WidthValue/(float)m_aVideoFormats[j].m_HeightValue > (float)m_aVideoFormats[j+1].m_WidthValue/(float)m_aVideoFormats[j+1].m_HeightValue)
|
||||
{
|
||||
CVideoFormat Tmp = m_aVideoFormats[j];
|
||||
m_aVideoFormats[j] = m_aVideoFormats[j+1];
|
||||
m_aVideoFormats[j+1] = Tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CMenus::UpdatedFilteredVideoModes()
|
||||
{
|
||||
m_lFilteredVideoModes.clear();
|
||||
for(int i = 0; i < m_NumModes; i++)
|
||||
{
|
||||
int G = gcd(m_aModes[i].m_Width, m_aModes[i].m_Height);
|
||||
if(m_aVideoFormats[m_CurrentVideoFormat].m_WidthValue == m_aModes[i].m_Width/G && m_aVideoFormats[m_CurrentVideoFormat].m_HeightValue == m_aModes[i].m_Height/G)
|
||||
m_lFilteredVideoModes.add(m_aModes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void CMenus::OnInit()
|
||||
{
|
||||
m_NumModes = Graphics()->GetVideoModes(m_aModes, MAX_RESOLUTIONS);
|
||||
UpdateVideoFormats();
|
||||
|
||||
bool Found = false;
|
||||
for(int i = 0; i < m_NumVideoFormats; i++)
|
||||
{
|
||||
int G = gcd(g_Config.m_GfxScreenWidth, g_Config.m_GfxScreenHeight);
|
||||
if(m_aVideoFormats[i].m_WidthValue == g_Config.m_GfxScreenWidth/G && m_aVideoFormats[i].m_HeightValue == g_Config.m_GfxScreenHeight/G)
|
||||
{
|
||||
m_CurrentVideoFormat = i;
|
||||
Found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!Found)
|
||||
m_CurrentVideoFormat = 0;
|
||||
|
||||
UpdatedFilteredVideoModes();
|
||||
|
||||
// load menu images
|
||||
m_lMenuImages.clear();
|
||||
Storage()->ListDirectory(IStorage::TYPE_ALL, "menuimages", MenuImageScan, this);
|
||||
|
@ -1144,11 +1522,11 @@ int CMenus::Render()
|
|||
if(Client()->State() != IClient::STATE_ONLINE && !m_pClient->m_pMapLayersBackGround->MenuMapLoaded())
|
||||
RenderBackground();
|
||||
|
||||
CUIRect TabBar;
|
||||
CUIRect TabBar, BottomView;
|
||||
CUIRect MainView;
|
||||
|
||||
// some margin around the screen
|
||||
Screen.Margin(10.0f, &Screen);
|
||||
//Screen.Margin(10.0f, &Screen);
|
||||
|
||||
static bool s_SoundCheck = false;
|
||||
if(!s_SoundCheck && m_Popup == POPUP_NONE)
|
||||
|
@ -1162,15 +1540,14 @@ int CMenus::Render()
|
|||
{
|
||||
if(m_MenuPage == PAGE_START && Client()->State() == IClient::STATE_OFFLINE)
|
||||
{
|
||||
RenderLogo(Screen);
|
||||
RenderStartMenu(Screen);
|
||||
RenderLogo(Screen);
|
||||
}
|
||||
else
|
||||
{
|
||||
// do tab bar
|
||||
Screen.VMargin(Screen.w/2-365.0f, &MainView);
|
||||
MainView.HMargin(20.0f, &MainView);
|
||||
MainView.HSplitTop(24.0f, &TabBar, &MainView);
|
||||
MainView.HSplitTop(60.0f, &TabBar, &MainView);
|
||||
RenderMenubar(TabBar);
|
||||
|
||||
// news is not implemented yet
|
||||
|
@ -1209,6 +1586,23 @@ int CMenus::Render()
|
|||
else if(m_MenuPage == PAGE_SETTINGS)
|
||||
RenderSettings(MainView);
|
||||
|
||||
// same size like tabs in top but variables not really needed
|
||||
float Spacing = 3.0f;
|
||||
float ButtonWidth = (MainView.w/6.0f)-(Spacing*5.0)/6.0f;
|
||||
|
||||
// render background
|
||||
MainView.HSplitBottom(60.0f, 0, &MainView);
|
||||
MainView.VSplitLeft(ButtonWidth, &MainView, 0);
|
||||
RenderTools()->DrawUIRect4(&MainView, vec4(0.0f, 0.0f, 0.0f, 0.25f), vec4(0.0f, 0.0f, 0.0f, 0.25f), vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f), CUI::CORNER_T, 5.0f);
|
||||
|
||||
// back to main menu
|
||||
CUIRect Button;
|
||||
MainView.HSplitTop(25.0f, &MainView, 0);
|
||||
Button = MainView;
|
||||
static int s_MenuButton=0;
|
||||
if(DoButton_Menu(&s_MenuButton, Localize("Back"), 0, &Button))
|
||||
m_MenuPage = PAGE_START;
|
||||
|
||||
// handle back with esc
|
||||
if(m_EscapePressed)
|
||||
m_MenuPage = PAGE_START;
|
||||
|
@ -1505,7 +1899,8 @@ int CMenus::Render()
|
|||
ActSelection = Country;
|
||||
static float s_ScrollValue = 0.0f;
|
||||
int OldSelected = -1;
|
||||
UiDoListboxStart(&s_ScrollValue, &Box, 50.0f, Localize("Country"), "", m_pClient->m_pCountryFlags->Num(), 6, OldSelected, s_ScrollValue);
|
||||
UiDoListboxHeader(&Box, Localize("Country"), 20.0f, 2.0f);
|
||||
UiDoListboxStart(&s_ScrollValue, 50.0f, "", m_pClient->m_pCountryFlags->Num(), 6, OldSelected, s_ScrollValue);
|
||||
|
||||
for(int i = 0; i < m_pClient->m_pCountryFlags->Num(); ++i)
|
||||
{
|
||||
|
@ -1667,7 +2062,7 @@ int CMenus::Render()
|
|||
}
|
||||
else if(m_Popup == POPUP_SAVE_SKIN)
|
||||
{
|
||||
CUIRect Yes, No;
|
||||
CUIRect Yes, No, EditBox;
|
||||
Box.HSplitBottom(20.f, &Box, &Part);
|
||||
Box.HSplitBottom(24.f, &Box, &Part);
|
||||
Part.VMargin(80.0f, &Part);
|
||||
|
@ -1677,16 +2072,25 @@ int CMenus::Render()
|
|||
Yes.VMargin(20.0f, &Yes);
|
||||
No.VMargin(20.0f, &No);
|
||||
|
||||
Box.HSplitBottom(Box.h/2.0f, 0, &Box);
|
||||
Box.HSplitTop(20.0f, &EditBox, &Box);
|
||||
|
||||
static float s_OffsetSaveSkin = 0.0f;
|
||||
DoEditBoxOption(m_aSaveSkinName, m_aSaveSkinName, sizeof(m_aSaveSkinName), &EditBox, Localize("Skin name"), 100.0f, &s_OffsetSaveSkin);
|
||||
|
||||
static int s_ButtonAbort = 0;
|
||||
if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed)
|
||||
m_Popup = POPUP_NONE;
|
||||
|
||||
static int s_ButtonTryAgain = 0;
|
||||
if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed)
|
||||
if(m_aSaveSkinName[0])
|
||||
{
|
||||
m_Popup = POPUP_NONE;
|
||||
SaveSkinfile();
|
||||
m_aSaveSkinName[0] = 0;
|
||||
static int s_ButtonTryAgain = 0;
|
||||
if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed)
|
||||
{
|
||||
m_Popup = POPUP_NONE;
|
||||
SaveSkinfile();
|
||||
m_aSaveSkinName[0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(m_Popup == POPUP_FIRST_LAUNCH)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <base/vmath.h>
|
||||
#include <base/tl/sorted_array.h>
|
||||
|
||||
#include <engine/graphics.h>
|
||||
#include <engine/demo.h>
|
||||
#include <engine/friends.h>
|
||||
|
||||
|
@ -28,18 +29,18 @@ public:
|
|||
|
||||
enum
|
||||
{
|
||||
NO_SELECTION=0,
|
||||
SELECTION_SKIN=1,
|
||||
SELECTION_BODY=2,
|
||||
SELECTION_TATTOO=4,
|
||||
SELECTION_DECORATION=8,
|
||||
SELECTION_HANDS=16,
|
||||
SELECTION_FEET=32,
|
||||
SELECTION_EYES=64
|
||||
SELECTION_BODY=0,
|
||||
SELECTION_TATTOO,
|
||||
SELECTION_DECORATION,
|
||||
SELECTION_HANDS,
|
||||
SELECTION_FEET,
|
||||
SELECTION_EYES
|
||||
};
|
||||
|
||||
class CMenus : public CComponent
|
||||
{
|
||||
typedef float (*FDropdownCallback)(CUIRect View, void *pUser);
|
||||
|
||||
float *ButtonFade(const void *pID, float Seconds, int Checked=0);
|
||||
|
||||
|
||||
|
@ -51,10 +52,10 @@ class CMenus : public CComponent
|
|||
int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, float r=5.0f, float FontFactor=0.0f, int Corners=CUI::CORNER_ALL);
|
||||
int DoButton_MenuImage(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName, float r=5.0f, float FontFactor=0.0f);
|
||||
int DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners);
|
||||
int DoButton_MenuTabTop(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners);
|
||||
int DoButton_MenuTabTop(const void *pID, const char *pText, int Checked, const CUIRect *pRect, float r=5.0f, float FontFactor=0.0f, int Corners=CUI::CORNER_ALL);
|
||||
int DoButton_Customize(const void *pID, IGraphics::CTextureHandle Texture, int SpriteID, const CUIRect *pRect, float ImageRatio);
|
||||
|
||||
int DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect);
|
||||
int DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect, bool Checked=false);
|
||||
int DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
||||
int DoButton_CheckBox_Number(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
||||
|
||||
|
@ -77,7 +78,11 @@ class CMenus : public CComponent
|
|||
static void ui_draw_checkbox(const void *id, const char *text, int checked, const CUIRect *r, const void *extra);
|
||||
static void ui_draw_checkbox_number(const void *id, const char *text, int checked, const CUIRect *r, const void *extra);
|
||||
*/
|
||||
int DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden=false, int Corners=CUI::CORNER_ALL);
|
||||
int DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden=false, int Corners=CUI::CORNER_ALL);
|
||||
void DoEditBoxOption(void *pID, char *pOption, int OptionLength, const CUIRect *pRect, const char *pStr, float VSplitVal, float *pOffset);
|
||||
void DoScrollbarOption(void *pID, int *pOption, const CUIRect *pRect, const char *pStr, float VSplitVal, int Min, int Max, bool infinite=false);
|
||||
float DoDropdownMenu(void *pID, const CUIRect *pRect, const char *pStr, float HeaderHeight, FDropdownCallback pfnCallback);
|
||||
void DoInfoBox(const CUIRect *pRect, const char *pLable, const char *pValue);
|
||||
//static int ui_do_edit_box(void *id, const CUIRect *rect, char *str, unsigned str_size, float font_size, bool hidden=false);
|
||||
|
||||
float DoScrollbarV(const void *pID, const CUIRect *pRect, float Current);
|
||||
|
@ -86,7 +91,7 @@ class CMenus : public CComponent
|
|||
int DoKeyReader(void *pID, const CUIRect *pRect, int Key);
|
||||
|
||||
//static int ui_do_key_reader(void *id, const CUIRect *rect, int key);
|
||||
void UiDoGetButtons(int Start, int Stop, CUIRect View);
|
||||
void UiDoGetButtons(int Start, int Stop, CUIRect View, float ButtonHeight, float Spaceing);
|
||||
|
||||
struct CListboxItem
|
||||
{
|
||||
|
@ -96,8 +101,9 @@ class CMenus : public CComponent
|
|||
CUIRect m_HitRect;
|
||||
};
|
||||
|
||||
void UiDoListboxStart(const void *pID, const CUIRect *pRect, float RowHeight, const char *pTitle, const char *pBottomText, int NumItems,
|
||||
int ItemsPerRow, int SelectedIndex, float ScrollValue);
|
||||
void UiDoListboxHeader(const CUIRect *pRect, const char *pTitle, float HeaderHeight, float Spaceing);
|
||||
void UiDoListboxStart(const void *pID, float RowHeight, const char *pBottomText, int NumItems,
|
||||
int ItemsPerRow, int SelectedIndex, float ScrollValue, const CUIRect *pRect=0);
|
||||
CListboxItem UiDoListboxNextItem(const void *pID, bool Selected = false);
|
||||
CListboxItem UiDoListboxNextRow();
|
||||
int UiDoListboxEnd(float *pScrollValue, bool *pItemActivated);
|
||||
|
@ -194,8 +200,7 @@ class CMenus : public CComponent
|
|||
// for settings
|
||||
bool m_NeedRestartGraphics;
|
||||
bool m_NeedRestartSound;
|
||||
int m_TeePartSelection;
|
||||
int m_TeePartsColorSelection;
|
||||
int m_TeePartSelected;
|
||||
char m_aSaveSkinName[24];
|
||||
|
||||
void SaveSkinfile();
|
||||
|
@ -216,6 +221,9 @@ class CMenus : public CComponent
|
|||
int m_CallvoteSelectedPlayer;
|
||||
char m_aCallvoteReason[VOTE_REASON_LENGTH];
|
||||
|
||||
// for callbacks
|
||||
int *m_pActiveDropdown;
|
||||
|
||||
// demo
|
||||
struct CDemoItem
|
||||
{
|
||||
|
@ -376,11 +384,32 @@ class CMenus : public CComponent
|
|||
|
||||
static CColumn ms_aCols[NUM_COLS];
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_RESOLUTIONS=256,
|
||||
};
|
||||
|
||||
CVideoMode m_aModes[MAX_RESOLUTIONS];
|
||||
int m_NumModes;
|
||||
|
||||
struct CVideoFormat
|
||||
{
|
||||
int m_WidthValue;
|
||||
int m_HeightValue;
|
||||
};
|
||||
|
||||
CVideoFormat m_aVideoFormats[MAX_RESOLUTIONS];
|
||||
sorted_array<CVideoMode> m_lFilteredVideoModes;
|
||||
int m_NumVideoFormats;
|
||||
int m_CurrentVideoFormat;
|
||||
void UpdateVideoFormats();
|
||||
void UpdatedFilteredVideoModes();
|
||||
|
||||
// found in menus.cpp
|
||||
int Render();
|
||||
//void render_background();
|
||||
//void render_loading(float percent);
|
||||
int RenderMenubar(CUIRect r);
|
||||
void RenderMenubar(CUIRect r);
|
||||
void RenderNews(CUIRect MainView);
|
||||
|
||||
// found in menus_demo.cpp
|
||||
|
@ -423,11 +452,20 @@ class CMenus : public CComponent
|
|||
void RenderSettingsGeneral(CUIRect MainView);
|
||||
void RenderSettingsPlayer(CUIRect MainView);
|
||||
void RenderSettingsTee(CUIRect MainView);
|
||||
void RenderSettingsTeeBasic(CUIRect MainView);
|
||||
void RenderSettingsTeeCustom(CUIRect MainView);
|
||||
void RenderSettingsControls(CUIRect MainView);
|
||||
void RenderSettingsGraphics(CUIRect MainView);
|
||||
void RenderSettingsSound(CUIRect MainView);
|
||||
void RenderSettings(CUIRect MainView);
|
||||
|
||||
// found in menu_callback.cpp
|
||||
static float RenderSettingsControlsMovement(CUIRect View, void *pUser);
|
||||
static float RenderSettingsControlsWeapon(CUIRect View, void *pUser);
|
||||
static float RenderSettingsControlsVoting(CUIRect View, void *pUser);
|
||||
static float RenderSettingsControlsChat(CUIRect View, void *pUser);
|
||||
static float RenderSettingsControlsMisc(CUIRect View, void *pUser);
|
||||
|
||||
void SetActive(bool Active);
|
||||
|
||||
void InvokePopupMenu(void *pID, int Flags, float X, float Y, float W, float H, int (*pfnFunc)(CMenus *pMenu, CUIRect Rect), void *pExtra=0);
|
||||
|
|
|
@ -1153,7 +1153,8 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
|
|||
// friends list(remove friend)
|
||||
static float s_ScrollValue = 0;
|
||||
static int s_FriendsList = 0;
|
||||
UiDoListboxStart(&s_FriendsList, &List, 30.0f, "", "", m_lFriends.size(), 1, m_FriendlistSelectedIndex, s_ScrollValue);
|
||||
UiDoListboxHeader(&List, "", 20.0f, 2.0f);
|
||||
UiDoListboxStart(&s_FriendsList, 30.0f, "", m_lFriends.size(), 1, m_FriendlistSelectedIndex, s_ScrollValue);
|
||||
|
||||
m_lFriends.sort_range();
|
||||
for(int i = 0; i < m_lFriends.size(); ++i)
|
||||
|
|
264
src/game/client/components/menus_callback.cpp
Normal file
264
src/game/client/components/menus_callback.cpp
Normal file
|
@ -0,0 +1,264 @@
|
|||
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
||||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
#include <engine/shared/config.h>
|
||||
|
||||
#include "binds.h"
|
||||
#include "menus.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CLocConstString m_Name;
|
||||
const char *m_pCommand;
|
||||
int m_KeyId;
|
||||
} CKeyInfo;
|
||||
|
||||
static CKeyInfo gs_aKeys[] =
|
||||
{
|
||||
{ "Move left", "+left", 0}, // Localize - these strings are localized within CLocConstString
|
||||
{ "Move right", "+right", 0 },
|
||||
{ "Jump", "+jump", 0 },
|
||||
{ "Fire", "+fire", 0 },
|
||||
{ "Hook", "+hook", 0 },
|
||||
{ "Hammer", "+weapon1", 0 },
|
||||
{ "Pistol", "+weapon2", 0 },
|
||||
{ "Shotgun", "+weapon3", 0 },
|
||||
{ "Grenade", "+weapon4", 0 },
|
||||
{ "Laser", "+weapon5", 0 },
|
||||
{ "Next weapon", "+nextweapon", 0 },
|
||||
{ "Prev. weapon", "+prevweapon", 0 },
|
||||
{ "Vote yes", "vote yes", 0 },
|
||||
{ "Vote no", "vote no", 0 },
|
||||
{ "Chat", "chat all", 0 },
|
||||
{ "Team chat", "chat team", 0 },
|
||||
{ "Show chat", "+show_chat", 0 },
|
||||
{ "Emoticon", "+emote", 0 },
|
||||
{ "Spectator mode", "+spectate", 0 },
|
||||
{ "Spectate next", "spectate_next", 0 },
|
||||
{ "Spectate previous", "spectate_previous", 0 },
|
||||
{ "Console", "toggle_local_console", 0 },
|
||||
{ "Remote console", "toggle_remote_console", 0 },
|
||||
{ "Screenshot", "screenshot", 0 },
|
||||
{ "Scoreboard", "+scoreboard", 0 },
|
||||
{ "Respawn", "kill", 0 },
|
||||
{ "Ready", "ready_change", 0 },
|
||||
};
|
||||
|
||||
/* This is for scripts/update_localization.py to work, don't remove!
|
||||
Localize("Move left");Localize("Move right");Localize("Jump");Localize("Fire");Localize("Hook");Localize("Hammer");
|
||||
Localize("Pistol");Localize("Shotgun");Localize("Grenade");Localize("Laser");Localize("Next weapon");Localize("Prev. weapon");
|
||||
Localize("Vote yes");Localize("Vote no");Localize("Chat");Localize("Team chat");Localize("Show chat");Localize("Emoticon");
|
||||
Localize("Spectator mode");Localize("Spectate next");Localize("Spectate previous");Localize("Console");Localize("Remote console");
|
||||
Localize("Screenshot");Localize("Scoreboard");Localize("Respawn");Localize("Ready");
|
||||
*/
|
||||
|
||||
const int g_KeyCount = sizeof(gs_aKeys) / sizeof(CKeyInfo);
|
||||
|
||||
void CMenus::UiDoGetButtons(int Start, int Stop, CUIRect View, float ButtonHeight, float Spaceing)
|
||||
{
|
||||
for (int i = Start; i < Stop; i++)
|
||||
{
|
||||
View.HSplitTop(Spaceing, 0, &View);
|
||||
|
||||
CKeyInfo &Key = gs_aKeys[i];
|
||||
CUIRect Button, Label;
|
||||
View.HSplitTop(ButtonHeight, &Button, &View);
|
||||
RenderTools()->DrawUIRect(&Button, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
|
||||
|
||||
Button.VSplitMid(&Label, &Button);
|
||||
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "%s:", (const char *)Key.m_Name);
|
||||
|
||||
Label.y += 2.0f;
|
||||
UI()->DoLabelScaled(&Label, aBuf, 13.0f, 0);
|
||||
int OldId = Key.m_KeyId;
|
||||
int NewId = DoKeyReader((void *)&gs_aKeys[i].m_Name, &Button, OldId);
|
||||
if(NewId != OldId)
|
||||
{
|
||||
if(OldId != 0 || NewId == 0)
|
||||
m_pClient->m_pBinds->Bind(OldId, "");
|
||||
if(NewId != 0)
|
||||
m_pClient->m_pBinds->Bind(NewId, gs_aKeys[i].m_pCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float CMenus::RenderSettingsControlsMovement(CUIRect View, void *pUser)
|
||||
{
|
||||
CMenus *pSelf = (CMenus*)pUser;
|
||||
|
||||
// this is kinda slow, but whatever
|
||||
for(int i = 0; i < g_KeyCount; i++)
|
||||
gs_aKeys[i].m_KeyId = 0;
|
||||
|
||||
for(int KeyId = 0; KeyId < KEY_LAST; KeyId++)
|
||||
{
|
||||
const char *pBind = pSelf->m_pClient->m_pBinds->Get(KeyId);
|
||||
if(!pBind[0])
|
||||
continue;
|
||||
|
||||
for(int i = 0; i < g_KeyCount; i++)
|
||||
if(str_comp(pBind, gs_aKeys[i].m_pCommand) == 0)
|
||||
{
|
||||
gs_aKeys[i].m_KeyId = KeyId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int NumOptions = 6;
|
||||
float ButtonHeight = 20.0f;
|
||||
float Spaceing = 2.0f;
|
||||
float BackgroundHeight = (float)NumOptions*ButtonHeight+(float)NumOptions*Spaceing;
|
||||
|
||||
View.HSplitTop(BackgroundHeight, &View, 0);
|
||||
pSelf->RenderTools()->DrawUIRect(&View, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_B, 5.0f);
|
||||
|
||||
CUIRect Button;
|
||||
View.HSplitTop(Spaceing, 0, &View);
|
||||
View.HSplitTop(ButtonHeight, &Button, &View);
|
||||
pSelf->DoScrollbarOption(&g_Config.m_InpMousesens, &g_Config.m_InpMousesens, &Button, Localize("Mouse sens."), 150.0f, 5, 500);
|
||||
|
||||
pSelf->UiDoGetButtons(0, 5, View, ButtonHeight, Spaceing);
|
||||
|
||||
return BackgroundHeight;
|
||||
}
|
||||
|
||||
float CMenus::RenderSettingsControlsWeapon(CUIRect View, void *pUser)
|
||||
{
|
||||
CMenus *pSelf = (CMenus*)pUser;
|
||||
|
||||
// this is kinda slow, but whatever
|
||||
for(int i = 0; i < g_KeyCount; i++)
|
||||
gs_aKeys[i].m_KeyId = 0;
|
||||
|
||||
for(int KeyId = 0; KeyId < KEY_LAST; KeyId++)
|
||||
{
|
||||
const char *pBind = pSelf->m_pClient->m_pBinds->Get(KeyId);
|
||||
if(!pBind[0])
|
||||
continue;
|
||||
|
||||
for(int i = 0; i < g_KeyCount; i++)
|
||||
if(str_comp(pBind, gs_aKeys[i].m_pCommand) == 0)
|
||||
{
|
||||
gs_aKeys[i].m_KeyId = KeyId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int NumOptions = 7;
|
||||
float ButtonHeight = 20.0f;
|
||||
float Spaceing = 2.0f;
|
||||
float BackgroundHeight = (float)NumOptions*ButtonHeight+(float)NumOptions*Spaceing;
|
||||
|
||||
View.HSplitTop(BackgroundHeight, &View, 0);
|
||||
pSelf->RenderTools()->DrawUIRect(&View, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_B, 5.0f);
|
||||
|
||||
pSelf->UiDoGetButtons(5, 12, View, ButtonHeight, Spaceing);
|
||||
|
||||
return BackgroundHeight;
|
||||
}
|
||||
|
||||
float CMenus::RenderSettingsControlsVoting(CUIRect View, void *pUser)
|
||||
{
|
||||
CMenus *pSelf = (CMenus*)pUser;
|
||||
|
||||
// this is kinda slow, but whatever
|
||||
for(int i = 0; i < g_KeyCount; i++)
|
||||
gs_aKeys[i].m_KeyId = 0;
|
||||
|
||||
for(int KeyId = 0; KeyId < KEY_LAST; KeyId++)
|
||||
{
|
||||
const char *pBind = pSelf->m_pClient->m_pBinds->Get(KeyId);
|
||||
if(!pBind[0])
|
||||
continue;
|
||||
|
||||
for(int i = 0; i < g_KeyCount; i++)
|
||||
if(str_comp(pBind, gs_aKeys[i].m_pCommand) == 0)
|
||||
{
|
||||
gs_aKeys[i].m_KeyId = KeyId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int NumOptions = 2;
|
||||
float ButtonHeight = 20.0f;
|
||||
float Spaceing = 2.0f;
|
||||
float BackgroundHeight = (float)NumOptions*ButtonHeight+(float)NumOptions*Spaceing;
|
||||
|
||||
View.HSplitTop(BackgroundHeight, &View, 0);
|
||||
pSelf->RenderTools()->DrawUIRect(&View, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_B, 5.0f);
|
||||
|
||||
pSelf->UiDoGetButtons(12, 14, View, ButtonHeight, Spaceing);
|
||||
|
||||
return BackgroundHeight;
|
||||
}
|
||||
|
||||
float CMenus::RenderSettingsControlsChat(CUIRect View, void *pUser)
|
||||
{
|
||||
CMenus *pSelf = (CMenus*)pUser;
|
||||
|
||||
// this is kinda slow, but whatever
|
||||
for(int i = 0; i < g_KeyCount; i++)
|
||||
gs_aKeys[i].m_KeyId = 0;
|
||||
|
||||
for(int KeyId = 0; KeyId < KEY_LAST; KeyId++)
|
||||
{
|
||||
const char *pBind = pSelf->m_pClient->m_pBinds->Get(KeyId);
|
||||
if(!pBind[0])
|
||||
continue;
|
||||
|
||||
for(int i = 0; i < g_KeyCount; i++)
|
||||
if(str_comp(pBind, gs_aKeys[i].m_pCommand) == 0)
|
||||
{
|
||||
gs_aKeys[i].m_KeyId = KeyId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int NumOptions = 3;
|
||||
float ButtonHeight = 20.0f;
|
||||
float Spaceing = 2.0f;
|
||||
float BackgroundHeight = (float)NumOptions*ButtonHeight+(float)NumOptions*Spaceing;
|
||||
|
||||
View.HSplitTop(BackgroundHeight, &View, 0);
|
||||
pSelf->RenderTools()->DrawUIRect(&View, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_B, 5.0f);
|
||||
|
||||
pSelf->UiDoGetButtons(14, 17, View, ButtonHeight, Spaceing);
|
||||
|
||||
return BackgroundHeight;
|
||||
}
|
||||
|
||||
float CMenus::RenderSettingsControlsMisc(CUIRect View, void *pUser)
|
||||
{
|
||||
CMenus *pSelf = (CMenus*)pUser;
|
||||
|
||||
// this is kinda slow, but whatever
|
||||
for(int i = 0; i < g_KeyCount; i++)
|
||||
gs_aKeys[i].m_KeyId = 0;
|
||||
|
||||
for(int KeyId = 0; KeyId < KEY_LAST; KeyId++)
|
||||
{
|
||||
const char *pBind = pSelf->m_pClient->m_pBinds->Get(KeyId);
|
||||
if(!pBind[0])
|
||||
continue;
|
||||
|
||||
for(int i = 0; i < g_KeyCount; i++)
|
||||
if(str_comp(pBind, gs_aKeys[i].m_pCommand) == 0)
|
||||
{
|
||||
gs_aKeys[i].m_KeyId = KeyId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int NumOptions = 9;
|
||||
float ButtonHeight = 20.0f;
|
||||
float Spaceing = 2.0f;
|
||||
float BackgroundHeight = (float)NumOptions*ButtonHeight+(float)NumOptions*Spaceing;
|
||||
|
||||
View.HSplitTop(BackgroundHeight, &View, 0);
|
||||
pSelf->RenderTools()->DrawUIRect(&View, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_B, 5.0f);
|
||||
|
||||
pSelf->UiDoGetButtons(17, 26, View, ButtonHeight, Spaceing);
|
||||
|
||||
return BackgroundHeight;
|
||||
}
|
|
@ -254,210 +254,6 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
|||
}
|
||||
}
|
||||
|
||||
static CUIRect gs_ListBoxOriginalView;
|
||||
static CUIRect gs_ListBoxView;
|
||||
static float gs_ListBoxRowHeight;
|
||||
static int gs_ListBoxItemIndex;
|
||||
static int gs_ListBoxSelectedIndex;
|
||||
static int gs_ListBoxNewSelected;
|
||||
static int gs_ListBoxDoneEvents;
|
||||
static int gs_ListBoxNumItems;
|
||||
static int gs_ListBoxItemsPerRow;
|
||||
static float gs_ListBoxScrollValue;
|
||||
static bool gs_ListBoxItemActivated;
|
||||
|
||||
void CMenus::UiDoListboxStart(const void *pID, const CUIRect *pRect, float RowHeight, const char *pTitle, const char *pBottomText, int NumItems,
|
||||
int ItemsPerRow, int SelectedIndex, float ScrollValue)
|
||||
{
|
||||
CUIRect Scroll, Row;
|
||||
CUIRect View = *pRect;
|
||||
CUIRect Header, Footer;
|
||||
|
||||
// draw header
|
||||
View.HSplitTop(ms_ListheaderHeight, &Header, &View);
|
||||
RenderTools()->DrawUIRect(&Header, vec4(1,1,1,0.25f), CUI::CORNER_T, 5.0f);
|
||||
UI()->DoLabel(&Header, pTitle, Header.h*ms_FontmodHeight, 0);
|
||||
|
||||
// draw footers
|
||||
View.HSplitBottom(ms_ListheaderHeight, &View, &Footer);
|
||||
RenderTools()->DrawUIRect(&Footer, vec4(1,1,1,0.25f), CUI::CORNER_B, 5.0f);
|
||||
Footer.VSplitLeft(10.0f, 0, &Footer);
|
||||
UI()->DoLabel(&Footer, pBottomText, Header.h*ms_FontmodHeight, 0);
|
||||
|
||||
// background
|
||||
RenderTools()->DrawUIRect(&View, vec4(0,0,0,0.15f), 0, 0);
|
||||
|
||||
// prepare the scroll
|
||||
View.VSplitRight(15, &View, &Scroll);
|
||||
|
||||
// setup the variables
|
||||
gs_ListBoxOriginalView = View;
|
||||
gs_ListBoxSelectedIndex = SelectedIndex;
|
||||
gs_ListBoxNewSelected = SelectedIndex;
|
||||
gs_ListBoxItemIndex = 0;
|
||||
gs_ListBoxRowHeight = RowHeight;
|
||||
gs_ListBoxNumItems = NumItems;
|
||||
gs_ListBoxItemsPerRow = ItemsPerRow;
|
||||
gs_ListBoxDoneEvents = 0;
|
||||
gs_ListBoxScrollValue = ScrollValue;
|
||||
gs_ListBoxItemActivated = false;
|
||||
|
||||
// do the scrollbar
|
||||
View.HSplitTop(gs_ListBoxRowHeight, &Row, 0);
|
||||
|
||||
int NumViewable = (int)(gs_ListBoxOriginalView.h/Row.h) + 1;
|
||||
int Num = (NumItems+gs_ListBoxItemsPerRow-1)/gs_ListBoxItemsPerRow-NumViewable+1;
|
||||
if(Num < 0)
|
||||
Num = 0;
|
||||
if(Num > 0)
|
||||
{
|
||||
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_UP) && UI()->MouseInside(&View))
|
||||
gs_ListBoxScrollValue -= 3.0f/Num;
|
||||
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN) && UI()->MouseInside(&View))
|
||||
gs_ListBoxScrollValue += 3.0f/Num;
|
||||
|
||||
if(gs_ListBoxScrollValue < 0.0f) gs_ListBoxScrollValue = 0.0f;
|
||||
if(gs_ListBoxScrollValue > 1.0f) gs_ListBoxScrollValue = 1.0f;
|
||||
}
|
||||
|
||||
Scroll.HMargin(5.0f, &Scroll);
|
||||
gs_ListBoxScrollValue = DoScrollbarV(pID, &Scroll, gs_ListBoxScrollValue);
|
||||
|
||||
// the list
|
||||
gs_ListBoxView = gs_ListBoxOriginalView;
|
||||
gs_ListBoxView.VMargin(5.0f, &gs_ListBoxView);
|
||||
UI()->ClipEnable(&gs_ListBoxView);
|
||||
gs_ListBoxView.y -= gs_ListBoxScrollValue*Num*Row.h;
|
||||
}
|
||||
|
||||
CMenus::CListboxItem CMenus::UiDoListboxNextRow()
|
||||
{
|
||||
static CUIRect s_RowView;
|
||||
CListboxItem Item = {0};
|
||||
if(gs_ListBoxItemIndex%gs_ListBoxItemsPerRow == 0)
|
||||
gs_ListBoxView.HSplitTop(gs_ListBoxRowHeight /*-2.0f*/, &s_RowView, &gs_ListBoxView);
|
||||
|
||||
s_RowView.VSplitLeft(s_RowView.w/(gs_ListBoxItemsPerRow-gs_ListBoxItemIndex%gs_ListBoxItemsPerRow)/(UI()->Scale()), &Item.m_Rect, &s_RowView);
|
||||
|
||||
Item.m_Visible = 1;
|
||||
//item.rect = row;
|
||||
|
||||
Item.m_HitRect = Item.m_Rect;
|
||||
|
||||
//CUIRect select_hit_box = item.rect;
|
||||
|
||||
if(gs_ListBoxSelectedIndex == gs_ListBoxItemIndex)
|
||||
Item.m_Selected = 1;
|
||||
|
||||
// make sure that only those in view can be selected
|
||||
if(Item.m_Rect.y+Item.m_Rect.h > gs_ListBoxOriginalView.y)
|
||||
{
|
||||
|
||||
if(Item.m_HitRect.y < Item.m_HitRect.y) // clip the selection
|
||||
{
|
||||
Item.m_HitRect.h -= gs_ListBoxOriginalView.y-Item.m_HitRect.y;
|
||||
Item.m_HitRect.y = gs_ListBoxOriginalView.y;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
Item.m_Visible = 0;
|
||||
|
||||
// check if we need to do more
|
||||
if(Item.m_Rect.y > gs_ListBoxOriginalView.y+gs_ListBoxOriginalView.h)
|
||||
Item.m_Visible = 0;
|
||||
|
||||
gs_ListBoxItemIndex++;
|
||||
return Item;
|
||||
}
|
||||
|
||||
CMenus::CListboxItem CMenus::UiDoListboxNextItem(const void *pId, bool Selected)
|
||||
{
|
||||
int ThisItemIndex = gs_ListBoxItemIndex;
|
||||
if(Selected)
|
||||
{
|
||||
if(gs_ListBoxSelectedIndex == gs_ListBoxNewSelected)
|
||||
gs_ListBoxNewSelected = ThisItemIndex;
|
||||
gs_ListBoxSelectedIndex = ThisItemIndex;
|
||||
}
|
||||
|
||||
CListboxItem Item = UiDoListboxNextRow();
|
||||
|
||||
if(Item.m_Visible && UI()->DoButtonLogic(pId, "", gs_ListBoxSelectedIndex == gs_ListBoxItemIndex, &Item.m_HitRect))
|
||||
gs_ListBoxNewSelected = ThisItemIndex;
|
||||
|
||||
// process input, regard selected index
|
||||
if(gs_ListBoxSelectedIndex == ThisItemIndex)
|
||||
{
|
||||
if(!gs_ListBoxDoneEvents)
|
||||
{
|
||||
gs_ListBoxDoneEvents = 1;
|
||||
|
||||
if(m_EnterPressed || (UI()->ActiveItem() == pId && Input()->MouseDoubleClick()))
|
||||
{
|
||||
gs_ListBoxItemActivated = true;
|
||||
UI()->SetActiveItem(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < m_NumInputEvents; i++)
|
||||
{
|
||||
int NewIndex = -1;
|
||||
if(m_aInputEvents[i].m_Flags&IInput::FLAG_PRESS)
|
||||
{
|
||||
if(m_aInputEvents[i].m_Key == KEY_DOWN) NewIndex = gs_ListBoxNewSelected + 1;
|
||||
if(m_aInputEvents[i].m_Key == KEY_UP) NewIndex = gs_ListBoxNewSelected - 1;
|
||||
}
|
||||
if(NewIndex > -1 && NewIndex < gs_ListBoxNumItems)
|
||||
{
|
||||
// scroll
|
||||
float Offset = (NewIndex/gs_ListBoxItemsPerRow-gs_ListBoxNewSelected/gs_ListBoxItemsPerRow)*gs_ListBoxRowHeight;
|
||||
int Scroll = gs_ListBoxOriginalView.y > Item.m_Rect.y+Offset ? -1 :
|
||||
gs_ListBoxOriginalView.y+gs_ListBoxOriginalView.h < Item.m_Rect.y+Item.m_Rect.h+Offset ? 1 : 0;
|
||||
if(Scroll)
|
||||
{
|
||||
int NumViewable = (int)(gs_ListBoxOriginalView.h/gs_ListBoxRowHeight) + 1;
|
||||
int ScrollNum = (gs_ListBoxNumItems+gs_ListBoxItemsPerRow-1)/gs_ListBoxItemsPerRow-NumViewable+1;
|
||||
if(Scroll < 0)
|
||||
{
|
||||
int Num = (gs_ListBoxOriginalView.y-Item.m_Rect.y-Offset+gs_ListBoxRowHeight-1.0f)/gs_ListBoxRowHeight;
|
||||
gs_ListBoxScrollValue -= (1.0f/ScrollNum)*Num;
|
||||
}
|
||||
else
|
||||
{
|
||||
int Num = (Item.m_Rect.y+Item.m_Rect.h+Offset-(gs_ListBoxOriginalView.y+gs_ListBoxOriginalView.h)+gs_ListBoxRowHeight-1.0f)/
|
||||
gs_ListBoxRowHeight;
|
||||
gs_ListBoxScrollValue += (1.0f/ScrollNum)*Num;
|
||||
}
|
||||
if(gs_ListBoxScrollValue < 0.0f) gs_ListBoxScrollValue = 0.0f;
|
||||
if(gs_ListBoxScrollValue > 1.0f) gs_ListBoxScrollValue = 1.0f;
|
||||
}
|
||||
|
||||
gs_ListBoxNewSelected = NewIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//selected_index = i;
|
||||
CUIRect r = Item.m_Rect;
|
||||
r.Margin(1.5f, &r);
|
||||
RenderTools()->DrawUIRect(&r, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 4.0f);
|
||||
}
|
||||
|
||||
return Item;
|
||||
}
|
||||
|
||||
int CMenus::UiDoListboxEnd(float *pScrollValue, bool *pItemActivated)
|
||||
{
|
||||
UI()->ClipDisable();
|
||||
if(pScrollValue)
|
||||
*pScrollValue = gs_ListBoxScrollValue;
|
||||
if(pItemActivated)
|
||||
*pItemActivated = gs_ListBoxItemActivated;
|
||||
return gs_ListBoxNewSelected;
|
||||
}
|
||||
|
||||
int CMenus::DemolistFetchCallback(const char *pName, int IsDir, int StorageType, void *pUser)
|
||||
{
|
||||
CMenus *pSelf = (CMenus *)pUser;
|
||||
|
@ -504,6 +300,13 @@ void CMenus::DemolistOnUpdate(bool Reset)
|
|||
|
||||
void CMenus::RenderDemoList(CUIRect MainView)
|
||||
{
|
||||
CUIRect BottomView;
|
||||
MainView.HSplitTop(20.0f, 0, &MainView);
|
||||
|
||||
// cut view
|
||||
MainView.HSplitBottom(80.0f, &MainView, &BottomView);
|
||||
BottomView.HSplitTop(20.f, 0, &BottomView);
|
||||
|
||||
static int s_Inited = 0;
|
||||
if(!s_Inited)
|
||||
{
|
||||
|
@ -536,91 +339,13 @@ void CMenus::RenderDemoList(CUIRect MainView)
|
|||
}
|
||||
}
|
||||
|
||||
// render background
|
||||
RenderTools()->DrawUIRect(&MainView, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 10.0f);
|
||||
MainView.Margin(10.0f, &MainView);
|
||||
|
||||
CUIRect ButtonBar, RefreshRect, PlayRect, DeleteRect, RenameRect, FileIcon, ListBox;
|
||||
MainView.HSplitBottom(ms_ButtonHeight+5.0f, &MainView, &ButtonBar);
|
||||
ButtonBar.HSplitTop(5.0f, 0, &ButtonBar);
|
||||
ButtonBar.VSplitRight(130.0f, &ButtonBar, &PlayRect);
|
||||
ButtonBar.VSplitLeft(130.0f, &RefreshRect, &ButtonBar);
|
||||
ButtonBar.VSplitLeft(10.0f, 0, &ButtonBar);
|
||||
ButtonBar.VSplitLeft(120.0f, &DeleteRect, &ButtonBar);
|
||||
ButtonBar.VSplitLeft(10.0f, 0, &ButtonBar);
|
||||
ButtonBar.VSplitLeft(120.0f, &RenameRect, &ButtonBar);
|
||||
MainView.HSplitBottom(140.0f, &ListBox, &MainView);
|
||||
|
||||
// render demo info
|
||||
MainView.VMargin(5.0f, &MainView);
|
||||
MainView.HSplitBottom(5.0f, &MainView, 0);
|
||||
RenderTools()->DrawUIRect(&MainView, vec4(0,0,0,0.15f), CUI::CORNER_B, 4.0f);
|
||||
if(!m_DemolistSelectedIsDir && m_DemolistSelectedIndex >= 0 && m_lDemos[m_DemolistSelectedIndex].m_Valid)
|
||||
{
|
||||
CUIRect Left, Right, Labels;
|
||||
MainView.Margin(20.0f, &MainView);
|
||||
MainView.VSplitMid(&Labels, &MainView);
|
||||
|
||||
// left side
|
||||
Labels.HSplitTop(20.0f, &Left, &Labels);
|
||||
Left.VSplitLeft(150.0f, &Left, &Right);
|
||||
UI()->DoLabelScaled(&Left, Localize("Created:"), 14.0f, -1);
|
||||
UI()->DoLabelScaled(&Right, m_lDemos[m_DemolistSelectedIndex].m_Info.m_aTimestamp, 14.0f, -1);
|
||||
Labels.HSplitTop(5.0f, 0, &Labels);
|
||||
Labels.HSplitTop(20.0f, &Left, &Labels);
|
||||
Left.VSplitLeft(150.0f, &Left, &Right);
|
||||
UI()->DoLabelScaled(&Left, Localize("Type:"), 14.0f, -1);
|
||||
UI()->DoLabelScaled(&Right, m_lDemos[m_DemolistSelectedIndex].m_Info.m_aType, 14.0f, -1);
|
||||
Labels.HSplitTop(5.0f, 0, &Labels);
|
||||
Labels.HSplitTop(20.0f, &Left, &Labels);
|
||||
Left.VSplitLeft(150.0f, &Left, &Right);
|
||||
UI()->DoLabelScaled(&Left, Localize("Length:"), 14.0f, -1);
|
||||
int Length = ((m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[0]<<24)&0xFF000000) | ((m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[1]<<16)&0xFF0000) |
|
||||
((m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[2]<<8)&0xFF00) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[3]&0xFF);
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "%d:%02d", Length/60, Length%60);
|
||||
UI()->DoLabelScaled(&Right, aBuf, 14.0f, -1);
|
||||
Labels.HSplitTop(5.0f, 0, &Labels);
|
||||
Labels.HSplitTop(20.0f, &Left, &Labels);
|
||||
Left.VSplitLeft(150.0f, &Left, &Right);
|
||||
UI()->DoLabelScaled(&Left, Localize("Version:"), 14.0f, -1);
|
||||
str_format(aBuf, sizeof(aBuf), "%d", m_lDemos[m_DemolistSelectedIndex].m_Info.m_Version);
|
||||
UI()->DoLabelScaled(&Right, aBuf, 14.0f, -1);
|
||||
|
||||
// right side
|
||||
Labels = MainView;
|
||||
Labels.HSplitTop(20.0f, &Left, &Labels);
|
||||
Left.VSplitLeft(150.0f, &Left, &Right);
|
||||
UI()->DoLabelScaled(&Left, Localize("Map:"), 14.0f, -1);
|
||||
UI()->DoLabelScaled(&Right, m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapName, 14.0f, -1);
|
||||
Labels.HSplitTop(5.0f, 0, &Labels);
|
||||
Labels.HSplitTop(20.0f, &Left, &Labels);
|
||||
Left.VSplitLeft(20.0f, 0, &Left);
|
||||
Left.VSplitLeft(130.0f, &Left, &Right);
|
||||
UI()->DoLabelScaled(&Left, Localize("Size:"), 14.0f, -1);
|
||||
unsigned Size = (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[0]<<24) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[1]<<16) |
|
||||
(m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[2]<<8) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[3]);
|
||||
str_format(aBuf, sizeof(aBuf), Localize("%d Bytes"), Size);
|
||||
UI()->DoLabelScaled(&Right, aBuf, 14.0f, -1);
|
||||
Labels.HSplitTop(5.0f, 0, &Labels);
|
||||
Labels.HSplitTop(20.0f, &Left, &Labels);
|
||||
Left.VSplitLeft(20.0f, 0, &Left);
|
||||
Left.VSplitLeft(130.0f, &Left, &Right);
|
||||
UI()->DoLabelScaled(&Left, Localize("Crc:"), 14.0f, -1);
|
||||
unsigned Crc = (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[0]<<24) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[1]<<16) |
|
||||
(m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[2]<<8) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[3]);
|
||||
str_format(aBuf, sizeof(aBuf), "%08x", Crc);
|
||||
UI()->DoLabelScaled(&Right, aBuf, 14.0f, -1);
|
||||
Labels.HSplitTop(5.0f, 0, &Labels);
|
||||
Labels.HSplitTop(20.0f, &Left, &Labels);
|
||||
Left.VSplitLeft(150.0f, &Left, &Right);
|
||||
UI()->DoLabelScaled(&Left, Localize("Netversion:"), 14.0f, -1);
|
||||
UI()->DoLabelScaled(&Right, m_lDemos[m_DemolistSelectedIndex].m_Info.m_aNetversion, 14.0f, -1);
|
||||
}
|
||||
CUIRect ListBox, Button, Label, FileIcon;
|
||||
MainView.HSplitTop(230.0f, &ListBox, &MainView);
|
||||
|
||||
static int s_DemoListId = 0;
|
||||
static float s_ScrollValue = 0;
|
||||
UiDoListboxStart(&s_DemoListId, &ListBox, 17.0f, Localize("Demos"), aFooterLabel, m_lDemos.size(), 1, m_DemolistSelectedIndex, s_ScrollValue);
|
||||
UiDoListboxHeader(&ListBox, Localize("Recorded"), 20.0f, 2.0f);
|
||||
UiDoListboxStart(&s_DemoListId, 20.0f, 0, m_lDemos.size(), 1, m_DemolistSelectedIndex, s_ScrollValue);
|
||||
for(sorted_array<CDemoItem>::range r = m_lDemos.all(); !r.empty(); r.pop_front())
|
||||
{
|
||||
CListboxItem Item = UiDoListboxNextItem((void*)(&r.front()));
|
||||
|
@ -628,23 +353,140 @@ void CMenus::RenderDemoList(CUIRect MainView)
|
|||
{
|
||||
Item.m_Rect.VSplitLeft(Item.m_Rect.h, &FileIcon, &Item.m_Rect);
|
||||
Item.m_Rect.VSplitLeft(5.0f, 0, &Item.m_Rect);
|
||||
FileIcon.Margin(3.0f, &FileIcon);
|
||||
FileIcon.x += 3.0f;
|
||||
DoButton_Icon(IMAGE_FILEICONS, r.front().m_IsDir?SPRITE_FILE_FOLDER:SPRITE_FILE_DEMO1, &FileIcon);
|
||||
UI()->DoLabel(&Item.m_Rect, r.front().m_aName, Item.m_Rect.h*ms_FontmodHeight, -1);
|
||||
if(!str_comp(m_lDemos[m_DemolistSelectedIndex].m_aName, r.front().m_aName))
|
||||
{
|
||||
TextRender()->TextColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
TextRender()->TextOutlineColor(1.0f, 1.0f, 1.0f, 0.25f);
|
||||
Item.m_Rect.y += 2.0f;
|
||||
UI()->DoLabel(&Item.m_Rect, r.front().m_aName, Item.m_Rect.h*ms_FontmodHeight*0.8f, 0);
|
||||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Item.m_Rect.y += 2.0f;
|
||||
UI()->DoLabel(&Item.m_Rect, r.front().m_aName, Item.m_Rect.h*ms_FontmodHeight*0.8f, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
bool Activated = false;
|
||||
m_DemolistSelectedIndex = UiDoListboxEnd(&s_ScrollValue, &Activated);
|
||||
DemolistOnUpdate(false);
|
||||
|
||||
// render demo info
|
||||
int NumOptions = (!m_DemolistSelectedIsDir && m_DemolistSelectedIndex >= 0 && m_lDemos[m_DemolistSelectedIndex].m_Valid) ? 8 : 0;
|
||||
float ButtonHeight = 20.0f;
|
||||
float Spacing = 2.0f;
|
||||
float BackgroundHeight = (float)(NumOptions+1)*ButtonHeight+(float)NumOptions*Spacing;
|
||||
|
||||
MainView.HSplitTop(10.0f, 0, &MainView);
|
||||
MainView.HSplitTop(BackgroundHeight, &MainView, 0);
|
||||
RenderTools()->DrawUIRect(&MainView, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
|
||||
|
||||
MainView.HSplitTop(ButtonHeight, &Label, &MainView);
|
||||
Label.y += 2.0f;
|
||||
UI()->DoLabel(&Label, aFooterLabel, ButtonHeight*ms_FontmodHeight*0.8f, 0);
|
||||
if(!m_DemolistSelectedIsDir && m_DemolistSelectedIndex >= 0 && m_lDemos[m_DemolistSelectedIndex].m_Valid)
|
||||
{
|
||||
MainView.HSplitTop(Spacing, 0, &MainView);
|
||||
MainView.HSplitTop(ButtonHeight, &Button, &MainView);
|
||||
DoInfoBox(&Button, Localize("Created"), m_lDemos[m_DemolistSelectedIndex].m_Info.m_aTimestamp);
|
||||
|
||||
MainView.HSplitTop(Spacing, 0, &MainView);
|
||||
MainView.HSplitTop(ButtonHeight, &Button, &MainView);
|
||||
DoInfoBox(&Button, Localize("Type"), m_lDemos[m_DemolistSelectedIndex].m_Info.m_aType);
|
||||
|
||||
MainView.HSplitTop(Spacing, 0, &MainView);
|
||||
MainView.HSplitTop(ButtonHeight, &Button, &MainView);
|
||||
int Length = ((m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[0]<<24)&0xFF000000) | ((m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[1]<<16)&0xFF0000) |
|
||||
((m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[2]<<8)&0xFF00) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[3]&0xFF);
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "%d:%02d", Length/60, Length%60);
|
||||
DoInfoBox(&Button, Localize("Length"), aBuf);
|
||||
|
||||
MainView.HSplitTop(Spacing, 0, &MainView);
|
||||
MainView.HSplitTop(ButtonHeight, &Button, &MainView);
|
||||
str_format(aBuf, sizeof(aBuf), "%d", m_lDemos[m_DemolistSelectedIndex].m_Info.m_Version);
|
||||
DoInfoBox(&Button, Localize("Version"), aBuf);
|
||||
|
||||
MainView.HSplitTop(Spacing, 0, &MainView);
|
||||
MainView.HSplitTop(ButtonHeight, &Button, &MainView);
|
||||
DoInfoBox(&Button, Localize("Map"), m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapName);
|
||||
|
||||
MainView.HSplitTop(Spacing, 0, &MainView);
|
||||
MainView.HSplitTop(ButtonHeight, &Button, &MainView);
|
||||
unsigned Size = (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[0]<<24) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[1]<<16) |
|
||||
(m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[2]<<8) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[3]);
|
||||
str_format(aBuf, sizeof(aBuf), Localize("%d Bytes"), Size);
|
||||
DoInfoBox(&Button, Localize("Size"), aBuf);
|
||||
|
||||
MainView.HSplitTop(Spacing, 0, &MainView);
|
||||
MainView.HSplitTop(ButtonHeight, &Button, &MainView);
|
||||
unsigned Crc = (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[0]<<24) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[1]<<16) |
|
||||
(m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[2]<<8) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[3]);
|
||||
str_format(aBuf, sizeof(aBuf), "%08x", Crc);
|
||||
DoInfoBox(&Button, Localize("Crc"), aBuf);
|
||||
|
||||
MainView.HSplitTop(Spacing, 0, &MainView);
|
||||
MainView.HSplitTop(ButtonHeight, &Button, &MainView);
|
||||
DoInfoBox(&Button, Localize("Netversion"), m_lDemos[m_DemolistSelectedIndex].m_Info.m_aNetversion);
|
||||
}
|
||||
|
||||
// demo buttons
|
||||
int NumButtons = m_DemolistSelectedIsDir ? 2 : 4;
|
||||
Spacing = 3.0f;
|
||||
float ButtonWidth = (BottomView.w/6.0f)-(Spacing*5.0)/6.0f;
|
||||
float BackgroundWidth = ButtonWidth*(float)NumButtons+(float)(NumButtons-1)*Spacing;
|
||||
|
||||
BottomView.VSplitRight(BackgroundWidth, 0, &BottomView);
|
||||
RenderTools()->DrawUIRect4(&BottomView, vec4(0.0f, 0.0f, 0.0f, 0.25f), vec4(0.0f, 0.0f, 0.0f, 0.25f), vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f), CUI::CORNER_T, 5.0f);
|
||||
|
||||
BottomView.HSplitTop(25.0f, &BottomView, 0);
|
||||
BottomView.VSplitLeft(ButtonWidth, &Button, &BottomView);
|
||||
static int s_RefreshButton = 0;
|
||||
if(DoButton_Menu(&s_RefreshButton, Localize("Refresh"), 0, &RefreshRect))
|
||||
if(DoButton_Menu(&s_RefreshButton, Localize("Refresh"), 0, &Button))
|
||||
{
|
||||
DemolistPopulate();
|
||||
DemolistOnUpdate(false);
|
||||
}
|
||||
|
||||
if(!m_DemolistSelectedIsDir)
|
||||
{
|
||||
BottomView.VSplitLeft(Spacing, 0, &BottomView);
|
||||
BottomView.VSplitLeft(ButtonWidth, &Button, &BottomView);
|
||||
static int s_DeleteButton = 0;
|
||||
if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &Button) || m_DeletePressed)
|
||||
{
|
||||
if(m_DemolistSelectedIndex >= 0)
|
||||
{
|
||||
UI()->SetActiveItem(0);
|
||||
m_Popup = POPUP_DELETE_DEMO;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BottomView.VSplitLeft(Spacing, 0, &BottomView);
|
||||
BottomView.VSplitLeft(ButtonWidth, &Button, &BottomView);
|
||||
static int s_RenameButton = 0;
|
||||
if(DoButton_Menu(&s_RenameButton, Localize("Rename"), 0, &Button))
|
||||
{
|
||||
if(m_DemolistSelectedIndex >= 0)
|
||||
{
|
||||
UI()->SetActiveItem(0);
|
||||
m_Popup = POPUP_RENAME_DEMO;
|
||||
str_copy(m_aCurrentDemoFile, m_lDemos[m_DemolistSelectedIndex].m_aFilename, sizeof(m_aCurrentDemoFile));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BottomView.VSplitLeft(Spacing, 0, &BottomView);
|
||||
BottomView.VSplitLeft(ButtonWidth, &Button, &BottomView);
|
||||
static int s_PlayButton = 0;
|
||||
if(DoButton_Menu(&s_PlayButton, m_DemolistSelectedIsDir?Localize("Open"):Localize("Play"), 0, &PlayRect) || Activated)
|
||||
if(DoButton_Menu(&s_PlayButton, m_DemolistSelectedIsDir?Localize("Open"):Localize("Play"), 0, &Button) || Activated)
|
||||
{
|
||||
if(m_DemolistSelectedIndex >= 0)
|
||||
{
|
||||
|
@ -677,30 +519,4 @@ void CMenus::RenderDemoList(CUIRect MainView)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!m_DemolistSelectedIsDir)
|
||||
{
|
||||
static int s_DeleteButton = 0;
|
||||
if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &DeleteRect) || m_DeletePressed)
|
||||
{
|
||||
if(m_DemolistSelectedIndex >= 0)
|
||||
{
|
||||
UI()->SetActiveItem(0);
|
||||
m_Popup = POPUP_DELETE_DEMO;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static int s_RenameButton = 0;
|
||||
if(DoButton_Menu(&s_RenameButton, Localize("Rename"), 0, &RenameRect))
|
||||
{
|
||||
if(m_DemolistSelectedIndex >= 0)
|
||||
{
|
||||
UI()->SetActiveItem(0);
|
||||
m_Popup = POPUP_RENAME_DEMO;
|
||||
str_copy(m_aCurrentDemoFile, m_lDemos[m_DemolistSelectedIndex].m_aFilename, sizeof(m_aCurrentDemoFile));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -353,7 +353,8 @@ void CMenus::RenderServerControlServer(CUIRect MainView)
|
|||
static int s_VoteList = 0;
|
||||
static float s_ScrollValue = 0;
|
||||
CUIRect List = MainView;
|
||||
UiDoListboxStart(&s_VoteList, &List, 24.0f, "", "", m_pClient->m_pVoting->m_NumVoteOptions, 1, m_CallvoteSelectedOption, s_ScrollValue);
|
||||
UiDoListboxHeader(&List, "", 20.0f, 2.0f);
|
||||
UiDoListboxStart(&s_VoteList, 24.0f, "", m_pClient->m_pVoting->m_NumVoteOptions, 1, m_CallvoteSelectedOption, s_ScrollValue);
|
||||
|
||||
for(CVoteOptionClient *pOption = m_pClient->m_pVoting->m_pFirst; pOption; pOption = pOption->m_pNext)
|
||||
{
|
||||
|
@ -389,7 +390,8 @@ void CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators)
|
|||
static int s_VoteList = 0;
|
||||
static float s_ScrollValue = 0;
|
||||
CUIRect List = MainView;
|
||||
UiDoListboxStart(&s_VoteList, &List, 24.0f, "", "", NumOptions, 1, Selected, s_ScrollValue);
|
||||
UiDoListboxHeader(&List, "", 20.0f, 2.0f);
|
||||
UiDoListboxStart(&s_VoteList, 24.0f, "", NumOptions, 1, Selected, s_ScrollValue);
|
||||
|
||||
for(int i = 0; i < NumOptions; i++)
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -15,57 +15,111 @@
|
|||
|
||||
void CMenus::RenderStartMenu(CUIRect MainView)
|
||||
{
|
||||
CUIRect Menu;
|
||||
MainView.VMargin(MainView.w/2-190.0f, &Menu);
|
||||
Menu.HMargin(145.0f, &Menu);
|
||||
RenderTools()->DrawUIRect(&Menu, vec4(0,0,0,0.5f), CUI::CORNER_ALL, 10.0f);
|
||||
CUIRect TopMenu, BottomMenu;
|
||||
MainView.VMargin(MainView.w/2-190.0f, &TopMenu);
|
||||
TopMenu.HSplitTop(365.0f, &TopMenu, &BottomMenu);
|
||||
//TopMenu.HSplitBottom(145.0f, &TopMenu, 0);
|
||||
RenderTools()->DrawUIRect4(&TopMenu, vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.25f), vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_B, 10.0f);
|
||||
|
||||
Menu.Margin(5.0f, &Menu);
|
||||
TopMenu.HSplitTop(145.0f, 0, &TopMenu);
|
||||
|
||||
CUIRect Button;
|
||||
|
||||
Menu.HSplitTop(40.0f, &Button, &Menu);
|
||||
static int s_PlayButton = 0;
|
||||
if(DoButton_MenuImage(&s_PlayButton, Localize("Play Game"), 0, &Button, "play_game", 10.0f, 0.5f))
|
||||
m_MenuPage = g_Config.m_UiBrowserPage;
|
||||
|
||||
Menu.HSplitTop(5.0f, 0, &Menu); // little space
|
||||
Menu.HSplitTop(40.0f, &Button, &Menu);
|
||||
static int s_MapEditorButton = 0;
|
||||
if(DoButton_MenuImage(&s_MapEditorButton, Localize("Map Editor"), 0, &Button, "editor", 10.0f, 0.5f))
|
||||
{
|
||||
g_Config.m_ClEditor = 1;
|
||||
Input()->MouseModeRelative();
|
||||
}
|
||||
|
||||
Menu.HSplitTop(5.0f, 0, &Menu); // little space
|
||||
Menu.HSplitTop(40.0f, &Button, &Menu);
|
||||
static int s_DemoButton = 0;
|
||||
if(DoButton_MenuImage(&s_DemoButton, Localize("Demos"), 0, &Button, "demos", 10.0f, 0.5f))
|
||||
{
|
||||
m_MenuPage = PAGE_DEMOS;
|
||||
DemolistPopulate();
|
||||
DemolistOnUpdate(false);
|
||||
}
|
||||
|
||||
Menu.HSplitTop(5.0f, 0, &Menu); // little space
|
||||
Menu.HSplitTop(40.0f, &Button, &Menu);
|
||||
static int s_LocalServerButton = 0;
|
||||
if(DoButton_MenuImage(&s_LocalServerButton, Localize("Create Local Server"), 0, &Button, "local_server", 10.0f, 0.5f))
|
||||
{
|
||||
}
|
||||
|
||||
Menu.HSplitTop(5.0f, 0, &Menu); // little space
|
||||
Menu.HSplitTop(40.0f, &Button, &Menu);
|
||||
TopMenu.HSplitBottom(40.0f, &TopMenu, &Button);
|
||||
static int s_SettingsButton = 0;
|
||||
if(DoButton_MenuImage(&s_SettingsButton, Localize("Settings"), 0, &Button, "settings", 10.0f, 0.5f))
|
||||
if(g_Config.m_ClShowStartMenuImages)
|
||||
{
|
||||
m_MenuPage = PAGE_SETTINGS;
|
||||
if(DoButton_MenuImage(&s_SettingsButton, Localize("Settings"), 0, &Button, "settings", 10.0f, 0.5f))
|
||||
{
|
||||
m_MenuPage = PAGE_SETTINGS;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(DoButton_Menu(&s_SettingsButton, Localize("Settings"), 0, &Button, 10.0f, 0.5f))
|
||||
{
|
||||
m_MenuPage = PAGE_SETTINGS;
|
||||
}
|
||||
}
|
||||
|
||||
Menu.HSplitBottom(45.0f, &Menu, &Button);
|
||||
/*TopMenu.HSplitBottom(5.0f, &TopMenu, 0); // little space
|
||||
TopMenu.HSplitBottom(40.0f, &TopMenu, &Bottom);
|
||||
static int s_LocalServerButton = 0;
|
||||
if(g_Config.m_ClShowStartMenuImages)
|
||||
{
|
||||
if(DoButton_MenuImage(&s_LocalServerButton, Localize("Local server"), 0, &Button, "local_server", 10.0f, 0.5f))
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(DoButton_Menu(&s_LocalServerButton, Localize("Local server"), 0, &Button, 10.0f, 0.5f))
|
||||
{
|
||||
}
|
||||
}*/
|
||||
|
||||
TopMenu.HSplitBottom(5.0f, &TopMenu, 0); // little space
|
||||
TopMenu.HSplitBottom(40.0f, &TopMenu, &Button);
|
||||
static int s_DemoButton = 0;
|
||||
if(g_Config.m_ClShowStartMenuImages)
|
||||
{
|
||||
if(DoButton_MenuImage(&s_DemoButton, Localize("Demos"), 0, &Button, "demos", 10.0f, 0.5f))
|
||||
{
|
||||
m_MenuPage = PAGE_DEMOS;
|
||||
DemolistPopulate();
|
||||
DemolistOnUpdate(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(DoButton_Menu(&s_DemoButton, Localize("Demos"), 0, &Button, 10.0f, 0.5f))
|
||||
{
|
||||
m_MenuPage = PAGE_DEMOS;
|
||||
DemolistPopulate();
|
||||
DemolistOnUpdate(false);
|
||||
}
|
||||
}
|
||||
|
||||
TopMenu.HSplitBottom(5.0f, &TopMenu, 0); // little space
|
||||
TopMenu.HSplitBottom(40.0f, &TopMenu, &Button);
|
||||
static int s_MapEditorButton = 0;
|
||||
if(g_Config.m_ClShowStartMenuImages)
|
||||
{
|
||||
if(DoButton_MenuImage(&s_MapEditorButton, Localize("Editor"), 0, &Button, "editor", 10.0f, 0.5f))
|
||||
{
|
||||
g_Config.m_ClEditor = 1;
|
||||
Input()->MouseModeRelative();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(DoButton_Menu(&s_MapEditorButton, Localize("Editor"), 0, &Button, 10.0f, 0.5f))
|
||||
{
|
||||
g_Config.m_ClEditor = 1;
|
||||
Input()->MouseModeRelative();
|
||||
}
|
||||
}
|
||||
|
||||
TopMenu.HSplitBottom(5.0f, &TopMenu, 0); // little space
|
||||
TopMenu.HSplitBottom(40.0f, &TopMenu, &Button);
|
||||
static int s_PlayButton = 0;
|
||||
if(g_Config.m_ClShowStartMenuImages)
|
||||
{
|
||||
if(DoButton_MenuImage(&s_PlayButton, Localize("Play"), 0, &Button, "play_game", 10.0f, 0.5f))
|
||||
m_MenuPage = g_Config.m_UiBrowserPage;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(DoButton_Menu(&s_PlayButton, Localize("Play"), 0, &Button, 10.0f, 0.5f))
|
||||
m_MenuPage = g_Config.m_UiBrowserPage;
|
||||
}
|
||||
|
||||
BottomMenu.HSplitTop(90.0f, 0, &BottomMenu);
|
||||
RenderTools()->DrawUIRect4(&BottomMenu, vec4(0.0f, 0.0f, 0.0f, 0.25f), vec4(0.0f, 0.0f, 0.0f, 0.25f), vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f), CUI::CORNER_T, 10.0f);
|
||||
|
||||
BottomMenu.HSplitTop(40.0f, &Button, &TopMenu);
|
||||
static int s_QuitButton = 0;
|
||||
if(DoButton_Menu(&s_QuitButton, Localize("Quit Game"), 0, &Button, 15.0f, 0.5f))
|
||||
if(DoButton_Menu(&s_QuitButton, Localize("Quit"), 0, &Button, 10.0f, 0.5f))
|
||||
m_Popup = POPUP_QUIT;
|
||||
|
||||
// render version
|
||||
|
@ -89,7 +143,7 @@ void CMenus::RenderLogo(CUIRect MainView)
|
|||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_BANNER].m_Id);
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1,1,1,1);
|
||||
IGraphics::CQuadItem QuadItem(MainView.w/2-140, 70, 280, 70);
|
||||
IGraphics::CQuadItem QuadItem(MainView.w/2-140, 60, 280, 70);
|
||||
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
||||
Graphics()->QuadsEnd();
|
||||
}
|
||||
|
|
|
@ -177,6 +177,152 @@ void CRenderTools::DrawRoundRectExt(float x, float y, float w, float h, float r,
|
|||
Graphics()->QuadsDrawTL(ArrayQ, NumItems);
|
||||
}
|
||||
|
||||
void CRenderTools::DrawRoundRectExt4(float x, float y, float w, float h, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, float r, int Corners)
|
||||
{
|
||||
int Num = 8;
|
||||
for(int i = 0; i < Num; i+=2)
|
||||
{
|
||||
float a1 = i/(float)Num * pi/2;
|
||||
float a2 = (i+1)/(float)Num * pi/2;
|
||||
float a3 = (i+2)/(float)Num * pi/2;
|
||||
float Ca1 = cosf(a1);
|
||||
float Ca2 = cosf(a2);
|
||||
float Ca3 = cosf(a3);
|
||||
float Sa1 = sinf(a1);
|
||||
float Sa2 = sinf(a2);
|
||||
float Sa3 = sinf(a3);
|
||||
|
||||
if(Corners&1) // TL
|
||||
{
|
||||
Graphics()->SetColor(ColorTopLeft.r, ColorTopLeft.g, ColorTopLeft.b, ColorTopLeft.a);
|
||||
IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem(
|
||||
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);
|
||||
Graphics()->QuadsDrawFreeform(&ItemF, 1);
|
||||
}
|
||||
|
||||
if(Corners&2) // TR
|
||||
{
|
||||
Graphics()->SetColor(ColorTopRight.r, ColorTopRight.g, ColorTopRight.b, ColorTopRight.a);
|
||||
IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem(
|
||||
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);
|
||||
Graphics()->QuadsDrawFreeform(&ItemF, 1);
|
||||
}
|
||||
|
||||
if(Corners&4) // BL
|
||||
{
|
||||
Graphics()->SetColor(ColorBottomLeft.r, ColorBottomLeft.g, ColorBottomLeft.b, ColorBottomLeft.a);
|
||||
IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem(
|
||||
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);
|
||||
Graphics()->QuadsDrawFreeform(&ItemF, 1);
|
||||
}
|
||||
|
||||
if(Corners&8) // BR
|
||||
{
|
||||
Graphics()->SetColor(ColorBottomRight.r, ColorBottomRight.g, ColorBottomRight.b, ColorBottomRight.a);
|
||||
IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem(
|
||||
x+w-r, y+h-r,
|
||||
x+w-r+Ca1*r, y+h-r+Sa1*r,
|
||||
x+w-r+Ca3*r, y+h-r+Sa3*r,
|
||||
x+w-r+Ca2*r, y+h-r+Sa2*r);
|
||||
Graphics()->QuadsDrawFreeform(&ItemF, 1);
|
||||
}
|
||||
|
||||
if(Corners&16) // ITL
|
||||
{
|
||||
Graphics()->SetColor(ColorTopLeft.r, ColorTopLeft.g, ColorTopLeft.b, ColorTopLeft.a);
|
||||
IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem(
|
||||
x, y,
|
||||
x+(1-Ca1)*r, y-r+Sa1*r,
|
||||
x+(1-Ca3)*r, y-r+Sa3*r,
|
||||
x+(1-Ca2)*r, y-r+Sa2*r);
|
||||
Graphics()->QuadsDrawFreeform(&ItemF, 1);
|
||||
}
|
||||
|
||||
if(Corners&32) // ITR
|
||||
{
|
||||
Graphics()->SetColor(ColorTopRight.r, ColorTopRight.g, ColorTopRight.b, ColorTopRight.a);
|
||||
IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem(
|
||||
x+w, y,
|
||||
x+w-r+Ca1*r, y-r+Sa1*r,
|
||||
x+w-r+Ca3*r, y-r+Sa3*r,
|
||||
x+w-r+Ca2*r, y-r+Sa2*r);
|
||||
Graphics()->QuadsDrawFreeform(&ItemF, 1);
|
||||
}
|
||||
|
||||
if(Corners&64) // IBL
|
||||
{
|
||||
Graphics()->SetColor(ColorBottomLeft.r, ColorBottomLeft.g, ColorBottomLeft.b, ColorBottomLeft.a);
|
||||
IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem(
|
||||
x, y+h,
|
||||
x+(1-Ca1)*r, y+h+(1-Sa1)*r,
|
||||
x+(1-Ca3)*r, y+h+(1-Sa3)*r,
|
||||
x+(1-Ca2)*r, y+h+(1-Sa2)*r);
|
||||
Graphics()->QuadsDrawFreeform(&ItemF, 1);
|
||||
}
|
||||
|
||||
if(Corners&128) // IBR
|
||||
{
|
||||
Graphics()->SetColor(ColorBottomRight.r, ColorBottomRight.g, ColorBottomRight.b, ColorBottomRight.a);
|
||||
IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem(
|
||||
x+w, y+h,
|
||||
x+w-r+Ca1*r, y+h+(1-Sa1)*r,
|
||||
x+w-r+Ca3*r, y+h+(1-Sa3)*r,
|
||||
x+w-r+Ca2*r, y+h+(1-Sa2)*r);
|
||||
Graphics()->QuadsDrawFreeform(&ItemF, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Graphics()->SetColor4(ColorTopLeft, ColorTopRight, ColorBottomLeft, ColorBottomRight);
|
||||
IGraphics::CQuadItem ItemQ = IGraphics::CQuadItem(x+r, y+r, w-r*2, h-r*2); // center
|
||||
Graphics()->QuadsDrawTL(&ItemQ, 1);
|
||||
Graphics()->SetColor4(ColorTopLeft, ColorTopRight, ColorTopLeft, ColorTopRight);
|
||||
ItemQ = IGraphics::CQuadItem(x+r, y, w-r*2, r); // top
|
||||
Graphics()->QuadsDrawTL(&ItemQ, 1);
|
||||
Graphics()->SetColor4(ColorBottomLeft, ColorBottomRight, ColorBottomLeft, ColorBottomRight);
|
||||
ItemQ = IGraphics::CQuadItem(x+r, y+h-r, w-r*2, r); // bottom
|
||||
Graphics()->QuadsDrawTL(&ItemQ, 1);
|
||||
Graphics()->SetColor4(ColorTopLeft, ColorTopLeft, ColorBottomLeft, ColorBottomLeft);
|
||||
ItemQ = IGraphics::CQuadItem(x, y+r, r, h-r*2); // left
|
||||
Graphics()->QuadsDrawTL(&ItemQ, 1);
|
||||
Graphics()->SetColor4(ColorTopRight, ColorTopRight, ColorBottomRight, ColorBottomRight);
|
||||
ItemQ = IGraphics::CQuadItem(x+w-r, y+r, r, h-r*2); // right
|
||||
Graphics()->QuadsDrawTL(&ItemQ, 1);
|
||||
|
||||
if(!(Corners&1))
|
||||
{
|
||||
Graphics()->SetColor(ColorTopLeft.r, ColorTopLeft.g, ColorTopLeft.b, ColorTopLeft.a);
|
||||
IGraphics::CQuadItem ItemQ = IGraphics::CQuadItem(x, y, r, r); // TL
|
||||
Graphics()->QuadsDrawTL(&ItemQ, 1);
|
||||
}
|
||||
if(!(Corners&2))
|
||||
{
|
||||
Graphics()->SetColor(ColorTopRight.r, ColorTopRight.g, ColorTopRight.b, ColorTopRight.a);
|
||||
IGraphics::CQuadItem ItemQ = IGraphics::CQuadItem(x+w, y, -r, r); // TR
|
||||
Graphics()->QuadsDrawTL(&ItemQ, 1);
|
||||
}
|
||||
if(!(Corners&4))
|
||||
{
|
||||
Graphics()->SetColor(ColorBottomLeft.r, ColorBottomLeft.g, ColorBottomLeft.b, ColorBottomLeft.a);
|
||||
IGraphics::CQuadItem ItemQ = IGraphics::CQuadItem(x, y+h, r, -r); // BL
|
||||
Graphics()->QuadsDrawTL(&ItemQ, 1);
|
||||
}
|
||||
if(!(Corners&8))
|
||||
{
|
||||
Graphics()->SetColor(ColorBottomRight.r, ColorBottomRight.g, ColorBottomRight.b, ColorBottomRight.a);
|
||||
IGraphics::CQuadItem ItemQ = IGraphics::CQuadItem(x+w, y+h, -r, -r); // BR
|
||||
Graphics()->QuadsDrawTL(&ItemQ, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void CRenderTools::DrawRoundRect(float x, float y, float w, float h, float r)
|
||||
{
|
||||
DrawRoundRectExt(x,y,w,h,r,0xf);
|
||||
|
@ -193,6 +339,15 @@ void CRenderTools::DrawUIRect(const CUIRect *r, vec4 Color, int Corners, float R
|
|||
Graphics()->QuadsEnd();
|
||||
}
|
||||
|
||||
void CRenderTools::DrawUIRect4(const CUIRect *r, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, int Corners, float Rounding)
|
||||
{
|
||||
Graphics()->TextureClear();
|
||||
|
||||
Graphics()->QuadsBegin();
|
||||
DrawRoundRectExt4(r->x,r->y,r->w,r->h,ColorTopLeft,ColorTopRight,ColorBottomLeft,ColorBottomRight,Rounding*UI()->Scale(), Corners);
|
||||
Graphics()->QuadsEnd();
|
||||
}
|
||||
|
||||
void CRenderTools::RenderTee(CAnimState *pAnim, CTeeRenderInfo *pInfo, int Emote, vec2 Dir, vec2 Pos)
|
||||
{
|
||||
vec2 Direction = Dir;
|
||||
|
|
|
@ -58,8 +58,10 @@ public:
|
|||
// rects
|
||||
void DrawRoundRect(float x, float y, float w, float h, float r);
|
||||
void DrawRoundRectExt(float x, float y, float w, float h, float r, int Corners);
|
||||
void DrawRoundRectExt4(float x, float y, float w, float h, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, float r, int Corners);
|
||||
|
||||
void DrawUIRect(const CUIRect *pRect, vec4 Color, int Corners, float Rounding);
|
||||
void DrawUIRect4(const CUIRect *pRect, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, int Corners, float Rounding);
|
||||
|
||||
// larger rendering methods
|
||||
void RenderTilemapGenerateSkip(class CLayers *pLayers);
|
||||
|
|
|
@ -61,7 +61,7 @@ MACRO_CONFIG_STR(PlayerSkinEyes, player_skin_eyes, 24, "standard", CFGFLAG_CLIEN
|
|||
|
||||
//MACRO_CONFIG_INT(UiPage, ui_page, 6, 0, 10, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface page")
|
||||
MACRO_CONFIG_INT(UiBrowserPage, ui_browser_page, 6, 6, 8, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface serverbrowser page")
|
||||
MACRO_CONFIG_INT(UiSettingsPage, ui_settings_page, 0, 0, 4, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface settings page")
|
||||
MACRO_CONFIG_INT(UiSettingsPage, ui_settings_page, 0, 0, 5, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface settings page")
|
||||
//MACRO_CONFIG_INT(UiToolboxPage, ui_toolbox_page, 0, 0, 2, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Toolbox page")
|
||||
MACRO_CONFIG_STR(UiServerAddress, ui_server_address, 64, "localhost:8303", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface server address")
|
||||
MACRO_CONFIG_INT(UiMousesens, ui_mousesens, 100, 5, 100000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Mouse sensitivity for menus/editor")
|
||||
|
@ -69,8 +69,10 @@ MACRO_CONFIG_INT(UiMousesens, ui_mousesens, 100, 5, 100000, CFGFLAG_SAVE|CFGFLAG
|
|||
MACRO_CONFIG_INT(GfxNoclip, gfx_noclip, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Disable clipping")
|
||||
|
||||
MACRO_CONFIG_STR(ClBackgroundMap, cl_background_map, 64, "menu_night", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Background map")
|
||||
MACRO_CONFIG_INT(ClRotationRadius, cl_rotation_radius, 30, 1, 500, CFGFLAG_CLIENT|CFGFLAG_SAVE, "camera rotation radius")
|
||||
MACRO_CONFIG_INT(ClRotationSpeed, cl_rotation_speed, 40, 1, 120, CFGFLAG_CLIENT|CFGFLAG_SAVE, "camera rotations in seconds")
|
||||
MACRO_CONFIG_INT(ClRotationRadius, cl_rotation_radius, 30, 1, 500, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Camera rotation radius")
|
||||
MACRO_CONFIG_INT(ClRotationSpeed, cl_rotation_speed, 40, 1, 120, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Camera rotations in seconds")
|
||||
|
||||
MACRO_CONFIG_INT(ClShowStartMenuImages, cl_show_start_menu_images, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show start menu images")
|
||||
|
||||
// server
|
||||
MACRO_CONFIG_INT(SvWarmup, sv_warmup, 0, -1, 1000, CFGFLAG_SERVER, "Number of seconds to do warmup before match starts (0 disables, -1 all players ready)")
|
||||
|
|
Loading…
Reference in a new issue