2010-11-20 10:37:14 +00:00
|
|
|
/* (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. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef GAME_CLIENT_COMPONENTS_MENUS_H
|
|
|
|
#define GAME_CLIENT_COMPONENTS_MENUS_H
|
|
|
|
|
|
|
|
#include <base/vmath.h>
|
|
|
|
#include <base/tl/sorted_array.h>
|
|
|
|
|
2011-03-13 09:41:10 +00:00
|
|
|
#include <engine/demo.h>
|
2011-06-26 15:10:13 +00:00
|
|
|
#include <engine/friends.h>
|
2011-03-13 09:41:10 +00:00
|
|
|
|
2011-03-26 16:44:34 +00:00
|
|
|
#include <game/voting.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/component.h>
|
|
|
|
#include <game/client/ui.h>
|
|
|
|
|
|
|
|
|
|
|
|
// compnent to fetch keypresses, override all other input
|
|
|
|
class CMenusKeyBinder : public CComponent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool m_TakeKey;
|
|
|
|
bool m_GotKey;
|
|
|
|
IInput::CEvent m_Key;
|
|
|
|
CMenusKeyBinder();
|
|
|
|
virtual bool OnInput(IInput::CEvent Event);
|
|
|
|
};
|
|
|
|
|
|
|
|
class CMenus : public CComponent
|
2011-04-13 18:37:12 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
static vec4 ms_GuiColor;
|
|
|
|
static vec4 ms_ColorTabbarInactiveOutgame;
|
|
|
|
static vec4 ms_ColorTabbarActiveOutgame;
|
|
|
|
static vec4 ms_ColorTabbarInactiveIngame;
|
|
|
|
static vec4 ms_ColorTabbarActiveIngame;
|
|
|
|
static vec4 ms_ColorTabbarInactive;
|
|
|
|
static vec4 ms_ColorTabbarActive;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
vec4 ButtonColorMul(const void *pID);
|
|
|
|
|
|
|
|
|
|
|
|
int DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
2011-03-28 22:48:36 +00:00
|
|
|
int DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners);
|
2012-01-10 22:03:23 +00:00
|
|
|
int DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active);
|
2010-05-29 07:25:38 +00:00
|
|
|
int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
|
|
|
int DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners);
|
|
|
|
|
|
|
|
int DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect);
|
|
|
|
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);
|
|
|
|
|
|
|
|
/*static void ui_draw_menu_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra);
|
|
|
|
static void ui_draw_keyselect_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra);
|
|
|
|
static void ui_draw_menu_tab_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra);
|
|
|
|
static void ui_draw_settings_tab_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra);
|
|
|
|
*/
|
|
|
|
|
2010-11-17 18:46:50 +00:00
|
|
|
int DoButton_Icon(int ImageId, int SpriteId, const CUIRect *pRect);
|
2010-05-29 07:25:38 +00:00
|
|
|
int DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
|
|
|
|
|
|
|
//static void ui_draw_browse_icon(int what, const CUIRect *r);
|
|
|
|
//static void ui_draw_grid_header(const void *id, const char *text, int checked, const CUIRect *r, const void *extra);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
/*static void ui_draw_checkbox_common(const void *id, const char *text, const char *boxtext, const CUIRect *r, const void *extra);
|
|
|
|
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);
|
|
|
|
*/
|
2010-05-29 15:53:57 +00:00
|
|
|
int DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden=false, int Corners=CUI::CORNER_ALL);
|
2010-05-29 07:25:38 +00:00
|
|
|
//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);
|
|
|
|
float DoScrollbarH(const void *pID, const CUIRect *pRect, float Current);
|
|
|
|
void DoButton_KeySelect(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
|
|
|
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);
|
|
|
|
|
|
|
|
struct CListboxItem
|
|
|
|
{
|
|
|
|
int m_Visible;
|
|
|
|
int m_Selected;
|
|
|
|
CUIRect m_Rect;
|
|
|
|
CUIRect m_HitRect;
|
|
|
|
};
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-03-16 20:31:55 +00:00
|
|
|
void UiDoListboxStart(const void *pID, const CUIRect *pRect, float RowHeight, const char *pTitle, const char *pBottomText, int NumItems,
|
2011-04-13 18:37:12 +00:00
|
|
|
int ItemsPerRow, int SelectedIndex, float ScrollValue);
|
2011-03-16 20:31:55 +00:00
|
|
|
CListboxItem UiDoListboxNextItem(const void *pID, bool Selected = false);
|
2010-12-14 00:20:47 +00:00
|
|
|
CListboxItem UiDoListboxNextRow();
|
2010-05-29 07:25:38 +00:00
|
|
|
int UiDoListboxEnd(float *pScrollValue, bool *pItemActivated);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
//static void demolist_listdir_callback(const char *name, int is_dir, void *user);
|
|
|
|
//static void demolist_list_callback(const CUIRect *rect, int index, void *user);
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
POPUP_NONE=0,
|
|
|
|
POPUP_FIRST_LAUNCH,
|
|
|
|
POPUP_CONNECTING,
|
|
|
|
POPUP_MESSAGE,
|
|
|
|
POPUP_DISCONNECTED,
|
|
|
|
POPUP_PURE,
|
2010-12-12 18:20:30 +00:00
|
|
|
POPUP_LANGUAGE,
|
2011-06-29 20:27:32 +00:00
|
|
|
POPUP_COUNTRY,
|
2010-09-05 15:53:31 +00:00
|
|
|
POPUP_DELETE_DEMO,
|
2011-03-12 18:08:44 +00:00
|
|
|
POPUP_RENAME_DEMO,
|
2011-03-23 12:06:35 +00:00
|
|
|
POPUP_REMOVE_FRIEND,
|
2011-01-17 12:28:15 +00:00
|
|
|
POPUP_SOUNDERROR,
|
2010-05-29 07:25:38 +00:00
|
|
|
POPUP_PASSWORD,
|
2011-04-13 18:37:12 +00:00
|
|
|
POPUP_QUIT,
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PAGE_NEWS=1,
|
|
|
|
PAGE_GAME,
|
2011-04-06 18:18:31 +00:00
|
|
|
PAGE_PLAYERS,
|
2010-05-29 07:25:38 +00:00
|
|
|
PAGE_SERVER_INFO,
|
|
|
|
PAGE_CALLVOTE,
|
|
|
|
PAGE_INTERNET,
|
|
|
|
PAGE_LAN,
|
|
|
|
PAGE_FAVORITES,
|
|
|
|
PAGE_DEMOS,
|
|
|
|
PAGE_SETTINGS,
|
|
|
|
PAGE_SYSTEM,
|
2011-02-23 07:33:21 +00:00
|
|
|
PAGE_DDRace,
|
|
|
|
PAGE_BROWSER,
|
|
|
|
PAGE_GHOST
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int m_GamePage;
|
|
|
|
int m_Popup;
|
|
|
|
int m_ActivePage;
|
|
|
|
bool m_MenuActive;
|
|
|
|
bool m_UseMouseButtons;
|
|
|
|
vec2 m_MousePos;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int64 m_LastInput;
|
2011-02-27 16:56:03 +00:00
|
|
|
|
|
|
|
// loading
|
|
|
|
int m_LoadCurrent;
|
|
|
|
int m_LoadTotal;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
//
|
|
|
|
char m_aMessageTopic[512];
|
|
|
|
char m_aMessageBody[512];
|
|
|
|
char m_aMessageButton[512];
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void PopupMessage(const char *pTopic, const char *pBody, const char *pButton);
|
|
|
|
|
2011-04-13 18:37:12 +00:00
|
|
|
// TODO: this is a bit ugly but.. well.. yeah
|
2010-05-29 07:25:38 +00:00
|
|
|
enum { MAX_INPUTEVENTS = 32 };
|
|
|
|
static IInput::CEvent m_aInputEvents[MAX_INPUTEVENTS];
|
|
|
|
static int m_NumInputEvents;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// some settings
|
|
|
|
static float ms_ButtonHeight;
|
|
|
|
static float ms_ListheaderHeight;
|
|
|
|
static float ms_FontmodHeight;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-10-16 09:24:42 +00:00
|
|
|
// for settings
|
|
|
|
bool m_NeedRestartGraphics;
|
|
|
|
bool m_NeedRestartSound;
|
2010-05-29 07:25:38 +00:00
|
|
|
bool m_NeedSendinfo;
|
2011-03-16 20:31:55 +00:00
|
|
|
int m_SettingPlayerPage;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
//
|
|
|
|
bool m_EscapePressed;
|
|
|
|
bool m_EnterPressed;
|
2010-09-03 18:05:22 +00:00
|
|
|
bool m_DeletePressed;
|
2010-12-16 00:52:29 +00:00
|
|
|
|
|
|
|
// for map download popup
|
|
|
|
int64 m_DownloadLastCheckTime;
|
|
|
|
int m_DownloadLastCheckSize;
|
|
|
|
float m_DownloadSpeed;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// for call vote
|
|
|
|
int m_CallvoteSelectedOption;
|
|
|
|
int m_CallvoteSelectedPlayer;
|
2011-03-26 16:44:34 +00:00
|
|
|
char m_aCallvoteReason[VOTE_REASON_LENGTH];
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// demo
|
|
|
|
struct CDemoItem
|
|
|
|
{
|
2010-09-28 22:53:53 +00:00
|
|
|
char m_aFilename[128];
|
|
|
|
char m_aName[128];
|
|
|
|
bool m_IsDir;
|
2010-10-06 21:07:35 +00:00
|
|
|
int m_StorageType;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-11-20 13:45:09 +00:00
|
|
|
bool m_InfosLoaded;
|
2010-10-09 11:27:21 +00:00
|
|
|
bool m_Valid;
|
2011-03-13 09:41:10 +00:00
|
|
|
CDemoHeader m_Info;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-09-28 22:53:53 +00:00
|
|
|
bool operator<(const CDemoItem &Other) { return !str_comp(m_aFilename, "..") ? true : !str_comp(Other.m_aFilename, "..") ? false :
|
|
|
|
m_IsDir && !Other.m_IsDir ? true : !m_IsDir && Other.m_IsDir ? false :
|
|
|
|
str_comp_filenames(m_aFilename, Other.m_aFilename) < 0; }
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-02-13 05:35:13 +00:00
|
|
|
//sorted_array<CDemoItem> m_lDemos;
|
2010-06-04 20:14:02 +00:00
|
|
|
char m_aCurrentDemoFolder[256];
|
2011-03-12 18:08:44 +00:00
|
|
|
char m_aCurrentDemoFile[64];
|
2010-09-28 22:53:53 +00:00
|
|
|
int m_DemolistSelectedIndex;
|
|
|
|
bool m_DemolistSelectedIsDir;
|
2010-10-07 22:13:05 +00:00
|
|
|
int m_DemolistStorageType;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-09-28 22:53:53 +00:00
|
|
|
void DemolistOnUpdate(bool Reset);
|
2011-02-13 05:35:13 +00:00
|
|
|
//void DemolistPopulate();
|
2011-02-21 10:23:30 +00:00
|
|
|
static int DemolistFetchCallback(const char *pName, int IsDir, int StorageType, void *pUser);
|
2011-03-23 12:06:35 +00:00
|
|
|
|
2011-06-26 15:10:13 +00:00
|
|
|
// friends
|
|
|
|
struct CFriendItem
|
|
|
|
{
|
|
|
|
const CFriendInfo *m_pFriendInfo;
|
|
|
|
int m_NumFound;
|
|
|
|
|
|
|
|
bool operator<(const CFriendItem &Other)
|
|
|
|
{
|
|
|
|
if(m_NumFound && !Other.m_NumFound)
|
|
|
|
return true;
|
|
|
|
else if(!m_NumFound && Other.m_NumFound)
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int Result = str_comp(m_pFriendInfo->m_aName, Other.m_pFriendInfo->m_aName);
|
|
|
|
if(Result)
|
|
|
|
return Result < 0;
|
|
|
|
else
|
|
|
|
return str_comp(m_pFriendInfo->m_aClan, Other.m_pFriendInfo->m_aClan) < 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sorted_array<CFriendItem> m_lFriends;
|
2011-03-23 12:06:35 +00:00
|
|
|
int m_FriendlistSelectedIndex;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-06-26 15:10:13 +00:00
|
|
|
void FriendlistOnUpdate();
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// found in menus.cpp
|
|
|
|
int Render();
|
|
|
|
//void render_background();
|
|
|
|
//void render_loading(float percent);
|
|
|
|
int RenderMenubar(CUIRect r);
|
|
|
|
void RenderNews(CUIRect MainView);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// found in menus_demo.cpp
|
|
|
|
void RenderDemoPlayer(CUIRect MainView);
|
|
|
|
void RenderDemoList(CUIRect MainView);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// found in menus_ingame.cpp
|
|
|
|
void RenderGame(CUIRect MainView);
|
2011-04-06 18:18:31 +00:00
|
|
|
void RenderPlayers(CUIRect MainView);
|
2010-05-29 07:25:38 +00:00
|
|
|
void RenderServerInfo(CUIRect MainView);
|
|
|
|
void RenderServerControl(CUIRect MainView);
|
2011-03-26 15:56:59 +00:00
|
|
|
void RenderServerControlKick(CUIRect MainView, bool FilterSpectators);
|
2010-05-29 07:25:38 +00:00
|
|
|
void RenderServerControlServer(CUIRect MainView);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// found in menus_browser.cpp
|
|
|
|
int m_SelectedIndex;
|
2011-06-26 15:10:13 +00:00
|
|
|
int m_ScrollOffset;
|
2010-05-29 07:25:38 +00:00
|
|
|
void RenderServerbrowserServerList(CUIRect View);
|
|
|
|
void RenderServerbrowserServerDetail(CUIRect View);
|
|
|
|
void RenderServerbrowserFilters(CUIRect View);
|
2011-03-23 12:06:35 +00:00
|
|
|
void RenderServerbrowserFriends(CUIRect View);
|
2010-05-29 07:25:38 +00:00
|
|
|
void RenderServerbrowser(CUIRect MainView);
|
2011-06-26 15:10:13 +00:00
|
|
|
static void ConchainFriendlistUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
2010-07-04 14:10:00 +00:00
|
|
|
static void ConchainServerbrowserUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// found in menus_settings.cpp
|
2010-12-12 18:20:30 +00:00
|
|
|
void RenderLanguageSelection(CUIRect MainView);
|
2010-05-29 07:25:38 +00:00
|
|
|
void RenderSettingsGeneral(CUIRect MainView);
|
|
|
|
void RenderSettingsPlayer(CUIRect MainView);
|
2011-04-01 17:36:44 +00:00
|
|
|
void RenderSettingsTee(CUIRect MainView);
|
2010-05-29 07:25:38 +00:00
|
|
|
void RenderSettingsControls(CUIRect MainView);
|
|
|
|
void RenderSettingsGraphics(CUIRect MainView);
|
|
|
|
void RenderSettingsSound(CUIRect MainView);
|
|
|
|
void RenderSettings(CUIRect MainView);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void SetActive(bool Active);
|
|
|
|
public:
|
|
|
|
void RenderBackground();
|
|
|
|
|
|
|
|
void UseMouseButtons(bool Use) { m_UseMouseButtons = Use; }
|
|
|
|
|
|
|
|
static CMenusKeyBinder m_Binder;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CMenus();
|
|
|
|
|
2011-02-27 16:56:03 +00:00
|
|
|
void RenderLoading();
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
bool IsActive() const { return m_MenuActive; }
|
|
|
|
|
|
|
|
virtual void OnInit();
|
|
|
|
|
|
|
|
virtual void OnStateChange(int NewState, int OldState);
|
|
|
|
virtual void OnReset();
|
|
|
|
virtual void OnRender();
|
|
|
|
virtual bool OnInput(IInput::CEvent Event);
|
|
|
|
virtual bool OnMouseMove(float x, float y);
|
2011-01-30 16:21:41 +00:00
|
|
|
|
2011-04-09 06:41:31 +00:00
|
|
|
// DDRace
|
|
|
|
|
2011-01-30 16:21:41 +00:00
|
|
|
int DoButton_CheckBox_DontCare(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
2011-02-04 17:25:04 +00:00
|
|
|
sorted_array<CDemoItem> m_lDemos;
|
|
|
|
void DemolistPopulate();
|
2011-04-09 06:41:31 +00:00
|
|
|
|
|
|
|
// Ghost
|
2011-02-04 17:25:04 +00:00
|
|
|
struct CGhostItem
|
|
|
|
{
|
|
|
|
char m_aFilename[256];
|
|
|
|
char m_aPlayer[MAX_NAME_LENGTH];
|
2011-04-09 06:41:31 +00:00
|
|
|
|
2011-02-04 17:25:04 +00:00
|
|
|
float m_Time;
|
2011-04-09 06:41:31 +00:00
|
|
|
|
2011-02-04 17:25:04 +00:00
|
|
|
bool m_Active;
|
|
|
|
int m_ID;
|
2011-04-09 06:41:31 +00:00
|
|
|
|
2011-02-04 17:25:04 +00:00
|
|
|
bool operator<(const CGhostItem &Other) { return m_Time < Other.m_Time; }
|
2011-02-11 06:00:12 +00:00
|
|
|
bool operator==(const CGhostItem &Other) { return m_ID == Other.m_ID; }
|
2011-02-04 17:25:04 +00:00
|
|
|
};
|
2011-04-09 06:41:31 +00:00
|
|
|
|
2011-02-04 17:25:04 +00:00
|
|
|
sorted_array<CGhostItem> m_lGhosts;
|
2011-02-11 06:00:12 +00:00
|
|
|
CGhostItem *m_OwnGhost;
|
2011-02-23 07:33:21 +00:00
|
|
|
int m_DDRacePage;
|
2011-02-04 17:25:04 +00:00
|
|
|
void GhostlistPopulate();
|
2011-04-09 06:41:31 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
static int GhostlistFetchCallback(const char *pName, int IsDir, int StorageType, void *pUser);
|
|
|
|
|
|
|
|
// found in menus_ingame.cpp
|
|
|
|
void RenderInGameDDRace(CUIRect MainView);
|
|
|
|
void RenderGhost(CUIRect MainView);
|
|
|
|
void RenderInGameBrowser(CUIRect MainView);
|
|
|
|
|
|
|
|
// found in menus_settings.cpp
|
|
|
|
void RenderSettingsDDRace(CUIRect MainView);
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
#endif
|