Hard reset

This commit is contained in:
Ley0k 2016-03-27 11:49:47 +02:00
commit 09bed43f97
1594 changed files with 892326 additions and 0 deletions

42
code/uilib/editfield.h Normal file
View file

@ -0,0 +1,42 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __EDITFIELD_H__
#define __EDITFIELD_H__
class EditField {
public:
char m_buffer[ 256 ];
int m_cursor;
EditField();
};
inline
EditField::EditField()
{
m_buffer[ 0 ] = 0;
m_cursor = 0;
}
#endif

307
code/uilib/ucolor.cpp Normal file
View file

@ -0,0 +1,307 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ucolor.h"
UColor UClear( 0, 0, 0, 0 );
UColor UWhite( 1, 1, 1, 1 );
UColor UBlack( 0, 0, 0, 1 );
UColor ULightGrey( 0.875, 0.875, 0.875, 1.0 );
UColor UGrey( 0.75, 0.75, 0.75, 1.0 );
UColor UDarkGrey( 0.5, 0.5, 0.5, 1.0 );
UColor ULightRed( 1.0, 0.5, 0.5, 1.0 );
UColor URed( 1.0, 0.0, 0.0, 1.0 );
UColor UGreen( 0.0, 1.0, 0.0, 1.0 );
UColor ULightGreen( 0.5, 1.0, 0.5, 1.0 );
UColor UBlue( 0.0, 0.0, 1.0, 1.0 );
UColor UYellow( 1.0, 1.0, 0.0, 1.0 );
UColor UHudColor( 0.7f, 0.6f, 0.05f, 1.0f );
UColor::UColor
(
void
)
{
r = g = b = 0;
a = 1.0f;
}
UColor::UColor
(
float r,
float g,
float b,
float a
)
{
set( r, g, b, a );
}
UColor::UColor
(
UColorHSV hsv
)
{
float hh, p, q, t, ff;
int i;
if( hsv.s <= 0.0 ) {
r = hsv.v;
g = hsv.v;
b = hsv.v;
return;
}
hh = hsv.h;
if( hh >= 360.0 ) hh = 0.0;
hh /= 60.0;
i = ( long )hh;
ff = hh - i;
p = hsv.v * ( 1.0f - hsv.s );
q = hsv.v * ( 1.0f - ( hsv.s * ff ) );
t = hsv.v * ( 1.0f - ( hsv.s * ( 1.0f - ff ) ) );
switch( i ) {
case 0:
r = hsv.v;
g = t;
b = p;
break;
case 1:
r = q;
g = hsv.v;
b = p;
break;
case 2:
r = p;
g = hsv.v;
b = t;
break;
case 3:
r = p;
g = q;
b = hsv.v;
break;
case 4:
r = t;
g = p;
b = hsv.v;
break;
case 5:
default:
r = hsv.v;
g = p;
b = q;
break;
}
a = hsv.a;
}
UColor::operator float *( )
{
return ( float * )this;
}
UColor::operator float *( ) const
{
return ( float * )this;
}
void UColor::ScaleColor
(
float scale
)
{
r *= scale;
g *= scale;
b *= scale;
}
void UColor::ScaleAlpha
(
float scale
)
{
a *= scale;
}
void UColor::set
(
float r,
float g,
float b,
float a
)
{
this->r = r;
this->g = g;
this->b = b;
this->a = a;
}
UColorHSV::UColorHSV()
{
h = s = v = a = 0;
}
UColorHSV::UColorHSV
(
UColor rgb
)
{
float min;
float max;
float delta;
min = rgb.r < rgb.g ? rgb.r : rgb.g;
min = min < rgb.b ? min : rgb.b;
max = rgb.r > rgb.g ? rgb.r : rgb.g;
max = max > rgb.b ? max : rgb.b;
v = max;
delta = max - min;
if( delta < 0.00001 )
{
s = 0;
h = 0; // undefined, maybe NaN?
return;
}
// NOTE: if Max is == 0, this divide would cause a crash
if( max > 0.0 ) {
s = ( delta / max );
} else {
// if max is 0, then r = g = b = 0
// s = 0, v is undefined
s = 0.0;
h = 0/s; // (NAN), its now undefined
return;
}
if( rgb.r >= max ) {
// between yellow & magenta
h = ( rgb.g - rgb.b ) / delta;
} else {
if( rgb.g >= max ) {
// between cyan & yellow
h = 2.0f + ( rgb.b - rgb.r ) / delta;
} else {
// between magenta & cyan
h = 4.0f + ( rgb.r - rgb.g ) / delta;
}
// degrees
h *= 60.0;
}
if( h < 0.0 )
h += 360.0;
a = rgb.a;
}
UColorHSV::UColorHSV
(
float h,
float s,
float v,
float a
)
{
set( h, s, v, a );
}
void UColorHSV::set
(
float h,
float s,
float v,
float a
)
{
this->h = h;
this->s = s;
this->v = v;
this->a = a;
}
UBorderColor::UBorderColor()
{
}
UBorderColor::UBorderColor
(
const UColor& dark,
const UColor& reallydark,
const UColor& light
)
{
this->dark = dark;
this->reallydark = reallydark;
this->light = light;
}
UBorderColor::UBorderColor
(
const UColor& color
)
{
UColorHSV lighttemp;
dark.r = color.r * 0.6f;
dark.g = color.g * 0.6f;
dark.b = color.b * 0.6f;
dark.a = color.a;
reallydark.r = color.r * 0.3f;
reallydark.g = color.g * 0.3f;
reallydark.b = color.b * 0.3f;
reallydark.b = color.a;
lighttemp = color;
lighttemp.s *= 0.75f;
lighttemp.v *= 1.3f;
light = lighttemp;
original = color;
}
void UBorderColor::CreateSolidBorder
(
const UColor& color,
colorType_t type
)
{
// FIXME: stub
}

89
code/uilib/ucolor.h Normal file
View file

@ -0,0 +1,89 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UCOLOR_H__
#define __UCOLOR_H__
class UColor {
public:
float r;
float g;
float b;
float a;
UColor();
UColor( float r, float g, float b, float a );
UColor( class UColorHSV hsv );
operator float *( );
operator float *( ) const;
void ScaleColor( float scale );
void ScaleAlpha( float scale );
void set( float r, float g, float b, float a );
};
class UColorHSV {
public:
float h;
float s;
float v;
float a;
UColorHSV();
UColorHSV( UColor rgb );
UColorHSV( float h, float s, float v, float a );
void set( float h, float s, float v, float a );
};
typedef enum { DARK, REALLYDARK, LIGHT, NORMAL } colorType_t;
class UBorderColor {
public:
UColor dark;
UColor reallydark;
UColor light;
UColor original;
UBorderColor();
UBorderColor( const UColor& dark, const UColor& reallydark, const UColor& light );
UBorderColor( const UColor& color );
void CreateSolidBorder( const UColor& color, colorType_t type );
};
extern UColor UClear;
extern UColor UWhite;
extern UColor UBlack;
extern UColor ULightGrey;
extern UColor UGrey;
extern UColor UDarkGrey;
extern UColor ULightRed;
extern UColor URed;
extern UColor UGreen;
extern UColor ULightGreen;
extern UColor UBlue;
extern UColor UYellow;
extern UColor UHudColor;
#endif /* __UCOLOR_H__ */

88
code/uilib/ui_extern.h Normal file
View file

@ -0,0 +1,88 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UI_EXTERN_H__
#define __UI_EXTERN_H__
#include "../qcommon/q_shared.h"
#include "../qcommon/qcommon.h"
#include <listener.h>
#include <script.h>
#include "../client/client.h"
#include "ui_public.h"
#include "usignal.h"
#include "uisize2d.h"
#include "uipoint2d.h"
#include "uirect2d.h"
#include "ucolor.h"
#include "uifont.h"
#include "uiwidget.h"
#include "uimenu.h"
#include "ulist.h"
#include "uistatus.h"
#include "uilabel.h"
#include "uislider.h"
#include "uihorizscroll.h"
#include "uivertscroll.h"
#include "uibutton.h"
#include "../client/cl_uibind.h"
#include "uibind.h"
#include "uibindlist.h"
#include "uicheckbox.h"
#include "uifloatwnd.h"
#include "uipopupmenu.h"
#include "uiconsole.h"
#include "uidialog.h"
#include "editfield.h"
#include "uifield.h"
#include "uilangamelist.h"
#include "uiglobalgamelist.h"
#include "uilayout.h"
#include "uilist.h"
#include "uilistbox.h"
#include "uilistctrl.h"
#include "uimenu.h"
#include "uimledit.h"
#include "uinotepad.h"
#include "uipulldownmenu.h"
#include "uipulldownmenucontainer.h"
#include "uiwinman.h"
#include "../client/cl_uilangame.h"
#include "../client/cl_uiserverlist.h"
#include "../client/cl_uidmbox.h"
#include "../client/cl_uigmbox.h"
#include "../client/cl_uiminicon.h"
#include "../client/cl_uifilepicker.h"
#include "../client/cl_uimaprunner.h"
#include "../client/cl_uimpmappicker.h"
#include "../client/cl_uiplayermodelpicker.h"
#include "../client/cl_uisoundpicker.h"
#include "../client/cl_uiview3d.h"
#include "../client/cl_inv.h"
#include "../client/cl_invrender.h"
#include "../client/cl_uistd.h"
#include "../client/cl_uiloadsave.h"
#endif /* __UI_EXTERN_H__ */

164
code/uilib/ui_init.cpp Normal file
View file

@ -0,0 +1,164 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
uidef_t uid;
uiexport_t uie;
uiimport_t uii;
uiGlobals_t ui;
void UIE_AddFileToList( const char *name )
{
ui.fileList.AddTail( name );
}
void UIE_ResolutionChanged( void )
{
UIRect2D frame( 0, 0, uid.vidWidth, uid.vidHeight );
uWinMan.setFrame( frame );
uWinMan.RefreshShadersFromList();
}
void UI_GetMouseState( int *mouseX, int *mouseY, int *flags )
{
if( mouseX )
{
*mouseX = uid.mouseX;
}
if( mouseY )
{
*mouseY = uid.mouseY;
}
if( flags )
{
*flags = uid.mouseFlags;
}
}
int UI_GetCvarInt( const char *name, int def )
{
cvar_t *cvar = uii.Cvar_Find( name );
if( !cvar )
{
return def;
}
return cvar->integer;
}
float UI_GetCvarFloat( const char *name, float def )
{
cvar_t *cvar = uii.Cvar_Find( name );
if( !cvar )
{
return def;
}
return cvar->value;
}
const char *UI_GetCvarString( const char *cvar, char *def )
{
return uii.Cvar_GetString( cvar, def );
}
cvar_t *UI_FindCvar( const char *cvar )
{
return uii.Cvar_Find( cvar );
}
void UI_SetCvarInt( const char *cvar, int value )
{
char s[ 16 ];
sprintf( s, "%d", value );
uii.Cvar_Set( cvar, s );
}
void UI_SetCvarFloat( const char *cvar, float value )
{
char s[ 16 ];
sprintf( s, "%f", value );
uii.Cvar_Set( cvar, s );
}
void UI_ListFiles( const char *filespec )
{
ui.fileList.RemoveAllItems();
uii.File_ListFiles( filespec );
}
const char *UI_ConfigString( int index )
{
return uii.GetConfigstring( index );
}
void UI_Init( void )
{
UIRect2D frame( 0, 0, uid.vidWidth, uid.vidHeight );
ui.globalFont = new UIFont;
uWinMan.Init( frame, "verdana-12" );
UColor color( 0, 0, 0, 0 );
uWinMan.setBackgroundColor( color, true );
}
void UI_Shutdown( void )
{
if( ui.globalFont )
{
delete ui.globalFont;
ui.globalFont = NULL;
}
uWinMan.Shutdown();
}
void UI_InitExports()
{
uie.AddFileToList = UIE_AddFileToList;
uie.ResolutionChange = UIE_ResolutionChanged;
uie.Init = UI_Init;
uie.Shutdown = UI_Shutdown;
uie.FontStringWidth = UI_FontStringWidth;
//
// OLD implementation
//
/*
uie.KeyEvent = UI_KeyEvent;
uie.MouseEvent = UI_MouseEvent;
uie.Refresh = UI_Refresh;
uie.DrawHUD = UI_DrawHUD;
uie.IsFullscreen = UI_IsFullscreen;
uie.SetActiveMenu = UI_SetActiveMenu;
uie.ConsoleCommand = UI_ConsoleCommand;
uie.DrawConnectScreen = UI_DrawConnectScreen;
*/
}

37
code/uilib/ui_local.h Normal file
View file

@ -0,0 +1,37 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UI_LOCAL_H__
#define __UI_LOCAL_H__
#include "../client/cl_ui.h"
typedef struct uiGlobals_s {
UList<str> fileList;
UIFont *globalFont;
str clientData;
} uiGlobals_t;
extern uiGlobals_t ui;
#endif /* __UI_LOCAL_H__ */

233
code/uilib/ui_public.h Normal file
View file

@ -0,0 +1,233 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UI_PUBLIC_H__
#define __UI_PUBLIC_H__
class Event;
class Listener;
typedef int uihandle_t;
typedef struct tiki_s tiki_t;
/*typedef struct refEntity_t;
typedef struct polyVert_t;
typedef struct refdef_t;
typedef struct glconfig_t;*/
typedef struct {
connstate_t connState;
int connectPacketCount;
int clientNum;
char servername[ MAX_STRING_CHARS ];
char updateInfoString[ MAX_STRING_CHARS ];
char messageString[ MAX_STRING_CHARS ];
} uiClientState_t;
typedef enum {
UIMENU_NONE,
UIMENU_MAIN,
UIMENU_INGAME,
UIMENU_NEED_CD,
UIMENU_BAD_CD_KEY,
UIMENU_TEAM,
UIMENU_POSTGAME
} uiMenuCommand_t;
#define SORT_HOST 0
#define SORT_MAP 1
#define SORT_CLIENTS 2
#define SORT_GAME 3
#define SORT_PING 4
typedef struct uiimport_s {
uihandle_t( *Rend_RegisterMaterial )( const char *name );
uihandle_t( *Rend_RefreshMaterial )( const char *name );
void( *Rend_Set2D )( int x, int y, int w, int h, float left, float right, float bottom, float top, float n, float f );
void( *Rend_SetColor )( const float *rgba );
void( *Rend_Scissor )( int x, int y, int width, int height );
void( *Rend_DrawPicStretched )( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );
void( *Rend_DrawPicTiled )( float x, float y, float w, float h, qhandle_t hShader );
fontheader_t *( *Rend_LoadFont )( const char *name );
void( *Rend_DrawString )( fontheader_t *font, const char *text, float x, float y, int maxlen, qboolean bVirtualScreen );
void( *Rend_DrawBox )( float x, float y, float w, float h );
int( *Rend_GetShaderWidth )( qhandle_t hShader );
int( *Rend_GetShaderHeight )( qhandle_t hShader );
void ( *File_PickFile )( const char *name, Listener *obj, Event& event );
void ( *File_ListFiles )( const char *filespec );
int ( *File_OpenFile )( const char *qpath, void **buffer );
void ( *File_FreeFile )( void *buffer );
void ( *File_WriteFile )( const char *qpath, const void *buffer, int size );
uihandle_t ( *Snd_RegisterSound )( const char *sample, qboolean streamed );
void ( *Snd_PlaySound )( const char *sound_name );
qboolean ( *Alias_Add )( const char *alias, const char *name, const char *parameters );
const char *( *Alias_FindRandom )( const char *alias, AliasListNode_t **ret );
const char *( *Cvar_GetString )( const char *name, const char *defval );
cvar_t *( *Cvar_Find )( const char *var_name );
void ( *Cvar_Set )( const char *var_name, const char *value );
void ( *Cvar_Reset )( const char *var_name );
void ( *Cmd_Stuff )( const char *text );
void ( *Sys_Printf )( const char *text, ... );
void ( *Sys_Error )( int error, const char *text, ... );
void ( *Sys_DPrintf )( const char *text, ... );
int ( *Sys_Milliseconds )();
int ( *Sys_IsKeyDown )( int key );
const char *( *Sys_GetClipboard )( void );
void( *Sys_SetClipboard )( const char *foo );
const char *( *Cmd_CompleteCommandByNumber )( const char *partial, int number );
const char *( *Cvar_CompleteCvarByNumber )( const char *partial, int number );
void( *UI_WantsKeyboard )( void );
const char *( *Client_TranslateWidgetName )( const char *widget );
void( *Connect )( const char *server );
const char *( *Key_GetKeynameForCommand )( const char *command );
char *( *Key_GetCommandForKey )( int keynum );
void ( *Key_SetBinding )( int keynum, const char *binding );
void ( *Key_GetKeysForCommand )( const char *command, int *key1, int *key2 );
const char *( *Key_KeynumToString )( int keynum );
const char *( *GetConfigstring )( int index );
void ( *UI_CloseDMConsole )( void );
/*
cvar_t* (*Cvar_Get)( const char *var_name, const char *var_value, int flags );
int (*Argc)( void );
char* (*Argv)( int arg );
void (*Cmd_ExecuteText)( int exec_when, const char *text ); // don't use EXEC_NOW!
int (*FS_FOpenFile)( const char *qpath, fileHandle_t *f, fsMode_t mode );
int (*FS_Read)( void *buffer, int len, fileHandle_t f );
int (*FS_Write)( const void *buffer, int len, fileHandle_t f );
void (*FS_FCloseFile)( fileHandle_t f );
int (*FS_GetFileList)( const char *path, const char *extension, char *listbuf, int bufsize );
int (*FS_Seek)( fileHandle_t f, long offset, fsOrigin_t origin ); // fsOrigin_t
qhandle_t (*R_RegisterModel)( const char *name );
qhandle_t (*R_RegisterSkin)( const char *name );
qhandle_t (*R_RegisterShader)( const char *name );
qhandle_t (*R_RegisterShaderNoMip)( const char *name );
void (*R_ClearScene)( void );
void (*R_AddRefEntityToScene)( const refEntity_t *re, int parentEntityNumber );
qboolean (*R_AddPolyToScene)( qhandle_t hShader, int numVerts, const polyVert_t *verts, int renderfx );
void (*R_AddLightToScene)( const vec3_t org, float intensity, float r, float g, float b, int type );
void (*R_RenderScene)( const refdef_t *fd );
void (*R_SetColor)( const float *rgba );
void (*R_DrawStretchPic)( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );
void (*R_RotatedPic)( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader, float angle );
void (*UpdateScreen)( void );
int (*CM_LerpTag)( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName );
void (*S_StartLocalSound)( const char *sound_name, qboolean force_load );
sfxHandle_t (*S_RegisterSound)( const char *sample, qboolean compressed, qboolean force_load );
void (*Key_KeynumToStringBuf)( int keynum, char *buf, int buflen );
void (*Key_GetBindingBuf)( int keynum, char *buf, int buflen );
qboolean (*Key_IsDown)( int keynum );
qboolean (*Key_GetOverstrikeMode)( void );
void (*Key_SetOverstrikeMode)( qboolean state );
void (*Key_ClearStates)( void );
int (*Key_GetCatcher)( void );
void (*Key_SetCatcher)( int catcher );
void (*GetClipboardData)( char *buf, int bufsize );
void (*GetClientState)( uiClientState_t *state );
void (*GetGlconfig)( glconfig_t *glconfig );
int (*LAN_GetServerCount)( int source );
void (*LAN_GetServerAddressString)( int source, int n, char *buf, int buflen );
void (*LAN_GetServerInfo)( int source, int n, char *buf, int buflen );
int (*LAN_GetPingQueueCount)( void );
int (*LAN_ServerStatus)( const char *serverAddress, char *serverStatus, int maxLen );
void (*LAN_ClearPing)( int n );
void (*LAN_GetPing)( int n, char *buf, int buflen, int *pingtime );
void (*LAN_GetPingInfo)( int n, char *buf, int buflen );
int (*LAN_GetServerPing)( int source, int n );
void (*LAN_MarkServerVisible)( int source, int n, qboolean visible );
qboolean (*LAN_UpdateVisiblePings)( int source );
int (*MemoryRemaining)( void );
void (*GetCDKey)( char *buf, int buflen );
void (*SetCDKey)( char *buf );
qboolean (*VerifyCDKey)( const char *key, const char *chksum );
void (*SetPbClStatus)( int status );
void (*R_RegisterFont)( const char *fontName, int pointSize, fontInfo_t *font );
int (*R_Text_Width)( fontInfo_t *font, const char *text, int limit, qboolean useColourCodes );
int (*R_Text_Height)( fontInfo_t *font, const char *text, int limit, qboolean useColourCodes );
void (*R_Text_Paint)( fontInfo_t *font, float x, float y, float scale, float alpha, const char *text, float adjust, int limit, qboolean useColourCodes, qboolean is640 );
void (*R_Text_PaintChar)( fontInfo_t *font, float x, float y, float scale, int c, qboolean is640 );
dtiki_t* (*TIKI_RegisterModel)( const char *fname );
bone_t* (*TIKI_GetBones)( int numBones );
void (*TIKI_SetChannels)( tiki_t *tiki, int animIndex, float animTime, float animWeight, bone_t *bones );
void (*TIKI_AppendFrameBoundsAndRadius)( struct tiki_s *tiki, int animIndex, float animTime, float *outRadius, vec3_t outBounds[ 2 ] );
void (*TIKI_Animate)( tiki_t *tiki, bone_t *bones );
int (*TIKI_GetBoneNameIndex)( const char *boneName );
const char* (*R_GetShaderName)( qhandle_t shader );
*/
} uiimport_t;
#if 1
typedef struct uiexport_s {
void ( *AddFileToList )( const char *name );
void ( *ResolutionChange )( void );
void ( *Init )( void );
void ( *Shutdown )( void );
int ( *FontStringWidth )( fontheader_t *pFont, const char *pszString, int iMaxLen );
} uiexport_t;
#else
typedef struct uiexport_s {
void (*Init)( void );
void (*Shutdown)( void );
void (*KeyEvent)( int key, int down );
void (*MouseEvent)( int dx, int dy );
void (*Refresh)( int time );
void (*DrawHUD)( playerState_t *ps );
qboolean (*IsFullscreen)( void );
void (*SetActiveMenu)( uiMenuCommand_t menu );
qboolean (*ConsoleCommand)( int realTime );
void (*DrawConnectScreen)( qboolean overlay );
void (*AddFileToList)( const char *name );
void (*ResolutionChange)( void );
int (*FontStringWidth)( fontheader_t *pFont, const char *pszString, int iMaxLen );
} uiexport_t;
#endif
typedef struct uidef_s {
int time;
int vidWidth;
int vidHeight;
int mouseX;
int mouseY;
unsigned int mouseFlags;
int uiHasMouse;
} uidef_t;
extern uidef_t uid;
extern uiexport_t uie;
extern uiimport_t uii;
void UI_GetMouseState( int *mouseX, int *mouseY, int *flags );
int UI_GetCvarInt( const char *name, int def );
float UI_GetCvarFloat( const char *name, float def );
const char *UI_GetCvarString( const char *cvar, char *def );
cvar_t *UI_FindCvar( const char *cvar );
void UI_SetCvarInt( const char *cvar, int value );
void UI_SetCvarFloat( const char *cvar, float value );
void UI_ListFiles( const char *filespec );
const char *UI_ConfigString( int index );
void UI_Init( void );
void UI_Shutdown( void );
void UI_InitExports();
#endif

127
code/uilib/uibind.cpp Normal file
View file

@ -0,0 +1,127 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIButton, UIBindButton, NULL )
{
{ NULL, NULL }
};
UIBindButton::UIBindButton()
{
}
UIBindButton::UIBindButton
(
str entersound,
str activesound
)
{
// FIXME: stub
}
void UIBindButton::Pressed
(
Event *ev
)
{
// FIXME: stub
}
void UIBindButton::Pressed
(
void
)
{
// FIXME: stub
}
void UIBindButton::SetCommand
(
Event *ev
)
{
// FIXME: stub
}
void UIBindButton::SetCommand
(
str s
)
{
// FIXME: stub
}
void UIBindButton::DrawUnpressed
(
void
)
{
// FIXME: stub
}
void UIBindButton::DrawPressed
(
void
)
{
// FIXME: stub
}
void UIBindButton::Clear
(
void
)
{
// FIXME: stub
}
qboolean UIBindButton::KeyEvent
(
int key,
unsigned int time
)
{
// FIXME: stub
return qfalse;
}
void UIBindButton::SetAlternate
(
qboolean a
)
{
// FIXME: stub
}

55
code/uilib/uibind.h Normal file
View file

@ -0,0 +1,55 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIBIND_H__
#define __UIBIND_H__
class UIBindButton : public UIButton {
str m_bindcommand;
int m_bindindex;
qboolean m_getkey;
qboolean m_alternate;
str m_entersound;
str m_activesound;
str m_last_keyname;
UIReggedMaterial *m_mat;
public:
CLASS_PROTOTYPE( UIBindButton );
public:
UIBindButton();
UIBindButton( str entersound, str activesound );
void Pressed( Event *ev );
void Pressed( void );
void SetCommand( Event *ev );
void SetCommand( str s );
void DrawUnpressed( void );
void DrawPressed( void );
void Clear( void );
qboolean KeyEvent( int key, unsigned int time );
void SetAlternate( qboolean a );
};
#endif

230
code/uilib/uibindlist.cpp Normal file
View file

@ -0,0 +1,230 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
Event EV_UIFakkBindList_Filename
(
"filename",
EV_DEFAULT,
"s",
"filename",
"Filename that holds bind definitions"
);
Event EV_UIFakkBindList_StopBind
(
"stopbind",
EV_DEFAULT,
NULL,
NULL,
"stops trying to bind a key to a command"
);
CLASS_DECLARATION( UIWidget, UIFakkBindList, NULL )
{
{ &EV_UIFakkBindList_Filename, &UIFakkBindList::Filename },
{ &EV_UIFakkBindList_StopBind, &UIFakkBindList::StopBind },
{ NULL, NULL }
};
UIFakkBindList::UIFakkBindList()
{
// FIXME: stub
}
void UIFakkBindList::CreateBindWidgets
(
void
)
{
// FIXME: stub
}
void UIFakkBindList::DestroyBindWidgets
(
void
)
{
// FIXME: stub
}
void UIFakkBindList::RepositionBindWidgets
(
void
)
{
// FIXME: stub
}
void UIFakkBindList::DrawPressKey
(
UIRect2D frame
)
{
// FIXME: stub
}
void UIFakkBindList::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UIFakkBindList::Filename
(
Event *ev
)
{
// FIXME: stub
}
void UIFakkBindList::StopBind
(
Event *ev
)
{
// FIXME: stub
}
void UIFakkBindList::setBind
(
bind_t *b
)
{
// FIXME: stub
}
void UIFakkBindList::Draw
(
void
)
{
// FIXME: stub
}
bool UIFakkBindList::isDying
(
void
)
{
// FIXME: stub
return false;
}
qboolean UIFakkBindList::KeyEvent
(
int key,
unsigned int time
)
{
// FIXME: stub
return qfalse;
}
void UIFakkBindList::Highlight
(
UIWidget *wid
)
{
// FIXME: stub
}
void UIFakkBindList::PlayEnterSound
(
void
)
{
// FIXME: stub
}
qboolean UIFakkBindList::SetActiveRow
(
UIWidget *w
)
{
// FIXME: stub
return qfalse;
}
void UIFakkBindList::Realign
(
void
)
{
// FIXME: stub
}
CLASS_DECLARATION( UILabel, UIFakkBindListLabel, NULL )
{
{ NULL, NULL }
};
UIFakkBindListLabel::UIFakkBindListLabel()
{
// FIXME: stub
}
UIFakkBindListLabel::UIFakkBindListLabel
(
UIFakkBindList *list
)
{
// FIXME: stub
}
void UIFakkBindListLabel::Pressed
(
Event *ev
)
{
// FIXME: stub
}
void UIFakkBindListLabel::Draw
(
void
)
{
// FIXME: stub
}

82
code/uilib/uibindlist.h Normal file
View file

@ -0,0 +1,82 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIBINDLIST_H__
#define __UIBINDLIST_H__
class UIFakkBindList : public UIWidget {
bool m_created;
UIVertScroll *m_scroll;
UIReggedMaterial *m_presskey_mat;
UILabel *m_presskey_wid;
Container<UIWidget *> m_widgetlist;
Container<UIWidget *> m_miscwidgets;
int m_activerow;
int m_activeitem;
bind_t *m_bind;
public:
CLASS_PROTOTYPE( UIFakkBindList );
private:
void CreateBindWidgets( void );
void DestroyBindWidgets( void );
void RepositionBindWidgets( void );
void DrawPressKey( UIRect2D frame );
protected:
void FrameInitialized( void );
void Filename( Event *ev );
void StopBind( Event *ev );
public:
UIFakkBindList();
void setBind( bind_t *b );
void Draw( void );
bool isDying( void );
qboolean KeyEvent( int key, unsigned int time );
void Highlight( UIWidget *wid );
void PlayEnterSound( void );
qboolean SetActiveRow( UIWidget *w );
void Realign( void );
};
class UIFakkBindListLabel : public UILabel {
UIFakkBindList *m_list;
public:
CLASS_PROTOTYPE( UIFakkBindListLabel );
public:
UIFakkBindListLabel();
UIFakkBindListLabel( UIFakkBindList *list );
void Pressed( Event *ev );
void Draw( void );
};
extern Event EV_UIFakkBindList_Filename;
extern Event EV_UIFakkBindList_StopBind;
#endif

247
code/uilib/uibutton.cpp Normal file
View file

@ -0,0 +1,247 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UIButtonBase, NULL )
{
{ NULL, NULL }
};
UIButtonBase::UIButtonBase()
{
// FIXME: stub
}
void UIButtonBase::Pressed
(
Event *ev
)
{
// FIXME: stub
}
void UIButtonBase::Released
(
Event *ev
)
{
// FIXME: stub
}
void UIButtonBase::MouseEntered
(
Event *ev
)
{
// FIXME: stub
}
void UIButtonBase::MouseExited
(
Event *ev
)
{
// FIXME: stub
}
void UIButtonBase::Dragged
(
Event *ev
)
{
// FIXME: stub
}
void UIButtonBase::SetHoverSound
(
Event *ev
)
{
// FIXME: stub
}
void UIButtonBase::SetHoverCommand
(
Event *ev
)
{
// FIXME: stub
}
void UIButtonBase::Action
(
void
)
{
// FIXME: stub
}
CLASS_DECLARATION( UIButtonBase, UIButton, NULL )
{
{ NULL, NULL }
};
UIButton::UIButton()
{
// FIXME: stub
}
void UIButton::Draw
(
void
)
{
// FIXME: stub
}
void UIButton::DrawPressed
(
void
)
{
// FIXME: stub
}
void UIButton::DrawUnpressed
(
void
)
{
// FIXME: stub
}
qboolean UIButton::KeyEvent
(
int key,
unsigned int time
)
{
// FIXME: stub
return qfalse;
}
CLASS_DECLARATION( USignal, ToggleCVar, NULL )
{
{ NULL, NULL }
};
ToggleCVar::ToggleCVar()
{
// FIXME: stub
}
ToggleCVar::ToggleCVar
(
UIButton *button,
const char *cvar
)
{
// FIXME: stub
}
void ToggleCVar::Press
(
Event *ev
)
{
// FIXME: stub
}
void ToggleCVar::setCVar
(
const char *cvar
)
{
// FIXME: stub
}
void ToggleCVar::setButton
(
UIButton *button
)
{
// FIXME: stub
}
CLASS_DECLARATION( USignal, ExecCmd, NULL )
{
{ NULL, NULL }
};
ExecCmd::ExecCmd()
{
// FIXME: stub
}
ExecCmd::ExecCmd
(
UIButton *button,
const char *cmd
)
{
// FIXME: stub
}
void ExecCmd::Press
(
Event *ev
)
{
// FIXME: stub
}
void ExecCmd::setCommand
(
const char *cmd
)
{
// FIXME: stub
}
void ExecCmd::setButton
(
UIButton *button
)
{
// FIXME: stub
}

102
code/uilib/uibutton.h Normal file
View file

@ -0,0 +1,102 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIBUTTON_H__
#define __UIBUTTON_H__
class UIButtonBase : public UIWidget {
protected:
mouseState_t m_mouseState;
str m_hoverSound;
str m_hoverCommand;
public:
CLASS_PROTOTYPE( UIButtonBase );
protected:
void Pressed( Event *ev );
void Released( Event *ev );
void MouseEntered( Event *ev );
void MouseExited( Event *ev );
void Dragged( Event *ev );
void SetHoverSound( Event *ev );
void SetHoverCommand( Event *ev );
public:
UIButtonBase();
void Action( void );
};
class UIButton : public UIButtonBase {
public:
CLASS_PROTOTYPE( UIButton );
private:
void Draw( void );
virtual void DrawPressed( void );
virtual void DrawUnpressed( void );
public:
UIButton();
qboolean KeyEvent( int key, unsigned int time );
};
class ToggleCVar : public USignal {
protected:
str m_cvarname;
UIButton *m_button;
protected:
CLASS_PROTOTYPE( ToggleCVar );
void Press( Event *ev );
public:
ToggleCVar();
ToggleCVar( UIButton *button, const char *cvar );
void setCVar( const char *cvar );
void setButton( UIButton *button );
};
class ExecCmd : public USignal {
protected:
UIButton *m_button;
str m_cmd;
public:
CLASS_PROTOTYPE( ExecCmd );
protected:
void Press( Event *ev );
public:
ExecCmd();
ExecCmd( UIButton *button, const char *cmd );
void setCommand( const char *cmd );
void setButton( UIButton *button );
};
#endif

150
code/uilib/uicheckbox.cpp Normal file
View file

@ -0,0 +1,150 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UICheckBox, NULL )
{
{ NULL, NULL }
};
UICheckBox::UICheckBox()
{
// FIXME: stub
}
void UICheckBox::Draw
(
void
)
{
// FIXME: stub
}
void UICheckBox::CharEvent
(
int ch
)
{
// FIXME: stub
}
void UICheckBox::Pressed
(
Event *ev
)
{
// FIXME: stub
}
void UICheckBox::Released
(
Event *ev
)
{
// FIXME: stub
}
void UICheckBox::UpdateCvar
(
void
)
{
// FIXME: stub
}
void UICheckBox::MouseEntered
(
Event *ev
)
{
// FIXME: stub
}
void UICheckBox::MouseExited
(
Event *ev
)
{
// FIXME: stub
}
void UICheckBox::SetCheckedCommand
(
Event *ev
)
{
// FIXME: stub
}
void UICheckBox::SetUncheckedCommand
(
Event *ev
)
{
// FIXME: stub
}
void UICheckBox::SetCheckedShader
(
Event *ev
)
{
// FIXME: stub
}
void UICheckBox::SetUncheckedShader
(
Event *ev
)
{
// FIXME: stub
}
void UICheckBox::UpdateData
(
void
)
{
// FIXME: stub
}
bool UICheckBox::isChecked
(
void
)
{
// FIXME: stub
return false;
}

60
code/uilib/uicheckbox.h Normal file
View file

@ -0,0 +1,60 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UICHECKBOX_H__
#define __UICHECKBOX_H__
class UICheckBox : public UIWidget {
str m_checked_command;
str m_unchecked_command;
UIReggedMaterial *m_checked_material;
UIReggedMaterial *m_unchecked_material;
bool m_checked;
bool m_depressed;
float m_check_width;
float m_check_height;
public:
CLASS_PROTOTYPE( UICheckBox );
private:
void Draw( void );
void CharEvent( int ch );
void Pressed( Event *ev );
void Released( Event *ev );
void UpdateCvar( void );
void MouseEntered( Event *ev );
void MouseExited( Event *ev );
void SetCheckedCommand( Event *ev );
void SetUncheckedCommand( Event *ev );
void SetCheckedShader( Event *ev );
void SetUncheckedShader( Event *ev );
public:
UICheckBox( void );
void UpdateData( void );
bool isChecked( void );
};
#endif

23
code/uilib/uicommon.h Normal file
View file

@ -0,0 +1,23 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/

496
code/uilib/uiconsole.cpp Normal file
View file

@ -0,0 +1,496 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UIConsole, NULL )
{
{ NULL, NULL }
};
UIConsole::UIConsole()
{
}
int UIConsole::getFirstItem
(
void
)
{
// FIXME: stub
return 0;
}
int UIConsole::getNextItem
(
int prev
)
{
// FIXME: stub
return 0;
}
int UIConsole::getLastItem
(
void
)
{
// FIXME: stub
return 0;
}
int UIConsole::AddLine
(
void
)
{
// FIXME: stub
return 0;
}
void UIConsole::DrawBottomLine
(
void
)
{
// FIXME: stub
}
void UIConsole::AddHistory
(
void
)
{
// FIXME: stub
}
void UIConsole::Print
(
Event *ev
)
{
// FIXME: stub
}
void UIConsole::KeyEnter
(
void
)
{
// FIXME: stub
}
void UIConsole::setConsoleHandler
(
consoleHandler_t handler
)
{
// FIXME: stub
}
void UIConsole::AddText
(
const char *text,
UColor *pColor
)
{
// FIXME: stub
}
void UIConsole::CalcLineBreaks
(
item& theItem
)
{
// FIXME: stub
}
void UIConsole::Clear
(
void
)
{
// FIXME: stub
}
void UIConsole::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UIConsole::Draw
(
void
)
{
// FIXME: stub
}
void UIConsole::CharEvent
(
int ch
)
{
// FIXME: stub
}
qboolean UIConsole::KeyEvent
(
int key,
unsigned int time
)
{
// FIXME: stub
return qfalse;
}
void UIConsole::OnSizeChanged
(
Event *ev
)
{
// FIXME: stub
}
CLASS_DECLARATION( UIFloatingWindow, UIFloatingConsole, NULL )
{
{ NULL, NULL }
};
UIFloatingConsole::UIFloatingConsole()
{
// FIXME: stub
}
void UIFloatingConsole::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UIFloatingConsole::OnChildSizeChanged
(
Event *ev
)
{
// FIXME: stub
}
void UIFloatingConsole::AddText
(
const char *text,
UColor *pColor
)
{
// FIXME: stub
}
void UIFloatingConsole::setConsoleHandler
(
consoleHandler_t handler
)
{
// FIXME: stub
}
void UIFloatingConsole::Clear
(
void
)
{
// FIXME: stub
}
void UIFloatingConsole::OnClosePressed
(
Event *ev
)
{
// FIXME: stub
}
void UIFloatingConsole::setConsoleBackground
(
const UColor& color,
float alpha
)
{
// FIXME: stub
}
void UIFloatingConsole::setConsoleColor
(
const UColor& color
)
{
// FIXME: stub
}
CLASS_DECLARATION( UIConsole, UIDMConsole, NULL )
{
{ NULL, NULL }
};
UIDMConsole::UIDMConsole()
{
// FIXME: stub
}
void UIDMConsole::KeyEnter
(
void
)
{
// FIXME: stub
}
void UIDMConsole::AddDMMessageText
(
const char *text,
UColor *pColor
)
{
// FIXME: stub
}
void UIDMConsole::Draw
(
void
)
{
// FIXME: stub
}
qboolean UIDMConsole::KeyEvent
(
int key,
unsigned int time
)
{
// FIXME: stub
return qfalse;
}
qboolean UIDMConsole::GetQuickMessageMode
(
void
)
{
// FIXME: stub
return qfalse;
}
void UIDMConsole::SetQuickMessageMode
(
qboolean bQuickMessage
)
{
// FIXME: stub
}
int UIDMConsole::GetMessageMode
(
void
)
{
// FIXME: stub
return 0;
}
void UIDMConsole::SetMessageMode
(
int iMode
)
{
// FIXME: stub
}
CLASS_DECLARATION( UIFloatingConsole, UIFloatingDMConsole, NULL )
{
{ NULL, NULL }
};
UIFloatingDMConsole::UIFloatingDMConsole()
{
// FIXME: stub
}
void UIFloatingDMConsole::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UIFloatingDMConsole::OnChildSizeChanged
(
Event *ev
)
{
// FIXME: stub
}
void UIFloatingDMConsole::AddText
(
const char *text,
UColor *pColor
)
{
// FIXME: stub
}
void UIFloatingDMConsole::AddDMMessageText
(
const char *text,
UColor *pColor
)
{
// FIXME: stub
}
void UIFloatingDMConsole::setConsoleHandler
(
consoleHandler_t handler
)
{
// FIXME: stub
}
void UIFloatingDMConsole::Clear
(
void
)
{
// FIXME: stub
}
void UIFloatingDMConsole::OnClosePressed
(
Event *ev
)
{
// FIXME: stub
}
void UIFloatingDMConsole::setConsoleBackground
(
const UColor& color,
float alpha
)
{
// FIXME: stub
}
void UIFloatingDMConsole::setConsoleColor
(
const UColor& color
)
{
// FIXME: stub
}
qboolean UIFloatingDMConsole::GetQuickMessageMode
(
void
)
{
// FIXME: stub
return qfalse;
}
void UIFloatingDMConsole::SetQuickMessageMode
(
qboolean bQuickMessage
)
{
// FIXME: stub
}
int UIFloatingDMConsole::GetMessageMode
(
void
)
{
// FIXME: stub
return 0;
}
void UIFloatingDMConsole::SetMessageMode
(
int iMode
)
{
// FIXME: stub
}

172
code/uilib/uiconsole.h Normal file
View file

@ -0,0 +1,172 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UI_CONSOLE_H__
#define __UI_CONSOLE_H__
typedef void ( *consoleHandler_t )( const char *text );
class item {
public:
str string;
int lines;
int begins[ 10 ];
int breaks[ 10 ];
UColor *pColor;
item();
};
inline
item::item()
{
lines = 0;
for( int i = 0; i < 10; i++ )
{
begins[ i ] = 0;
breaks[ i ] = 0;
}
pColor = NULL;
}
class UIConsole : public UIWidget {
protected:
UList<str> m_history;
void *m_historyposition;
item m_items[ 300 ];
str m_currentline;
UIVertScroll *m_scroll;
int m_firstitem;
int m_numitems;
int m_caret;
str m_completionbuffer;
bool m_refreshcompletionbuffer;
int m_cntcmdnumber;
int m_cntcvarnumber;
consoleHandler_t m_consolehandler;
public:
CLASS_PROTOTYPE( UIConsole );
protected:
int getFirstItem( void );
int getNextItem( int prev );
int getLastItem( void );
int AddLine( void );
void DrawBottomLine( void );
void AddHistory( void );
virtual void Print( Event *ev );
virtual void KeyEnter( void );
public:
UIConsole();
void setConsoleHandler( consoleHandler_t handler );
void AddText( const char *text, UColor *pColor );
void CalcLineBreaks( item& theItem );
void Clear( void );
void FrameInitialized( void );
void Draw( void );
void CharEvent( int ch );
qboolean KeyEvent( int key, unsigned int time );
void OnSizeChanged( Event *ev );
};
class UIFloatingConsole : public UIFloatingWindow {
protected:
UIStatusBar *m_status;
SafePtr<UIConsole> m_console;
consoleHandler_t m_handler;
UColor m_consoleColor;
UColor m_consoleBackground;
float m_consoleAlpha;
public:
CLASS_PROTOTYPE( UIFloatingConsole );
UIFloatingConsole();
void FrameInitialized( void );
void OnChildSizeChanged( Event *ev );
void AddText( const char *text, UColor *pColor );
void setConsoleHandler( consoleHandler_t handler );
void Clear( void );
void OnClosePressed( Event *ev );
void setConsoleBackground( const UColor& color, float alpha );
void setConsoleColor( const UColor& color );
};
class UIDMConsole : public UIConsole {
qboolean m_bQuickMessageMode;
int m_iMessageMode;
public:
CLASS_PROTOTYPE( UIDMConsole );
private:
void KeyEnter( void );
public:
UIDMConsole();
void AddDMMessageText( const char *text, UColor *pColor );
void Draw( void );
qboolean KeyEvent( int key, unsigned int time );
qboolean GetQuickMessageMode( void );
void SetQuickMessageMode( qboolean bQuickMessage );
int GetMessageMode( void );
void SetMessageMode( int iMode );
};
class UIFloatingDMConsole : public UIFloatingWindow {
protected:
UIStatusBar *m_status;
SafePtr<UIDMConsole> m_console;
consoleHandler_t m_handler;
UColor m_consoleColor;
UColor m_consoleBackground;
float m_consoleAlpha;
public:
CLASS_PROTOTYPE( UIFloatingDMConsole );
UIFloatingDMConsole();
void FrameInitialized( void );
void OnChildSizeChanged( Event *ev );
void AddText( const char *text, UColor *pColor );
void AddDMMessageText( const char *text, UColor *pColor );
void setConsoleHandler( consoleHandler_t handler );
void Clear( void );
void OnClosePressed( Event *ev );
void setConsoleBackground( const UColor& color, float alpha );
void setConsoleColor( const UColor& color );
qboolean GetQuickMessageMode( void );
void SetQuickMessageMode( qboolean bQuickMessage );
int GetMessageMode( void );
void SetMessageMode( int iMode );
};
#endif

96
code/uilib/uidialog.cpp Normal file
View file

@ -0,0 +1,96 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIFloatingWindow, UIDialog, NULL )
{
{ NULL, NULL }
};
UIDialog::UIDialog()
{
// FIXME: stub
}
void UIDialog::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UIDialog::LinkCvar
(
str cvarname
)
{
// FIXME: stub
}
void UIDialog::SetOKCommand
(
str cvarname
)
{
// FIXME: stub
}
void UIDialog::SetCancelCommand
(
str cvarname
)
{
// FIXME: stub
}
void UIDialog::SetLabelMaterial
(
UIReggedMaterial *mat
)
{
// FIXME: stub
}
void UIDialog::SetOkMaterial
(
UIReggedMaterial *mat
)
{
// FIXME: stub
}
void UIDialog::SetCancelMaterial
(
UIReggedMaterial *mat
)
{
// FIXME: stub
}

47
code/uilib/uidialog.h Normal file
View file

@ -0,0 +1,47 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIDIALOG_H__
#define __UIDIALOG_H__
class UIDialog : public UIFloatingWindow {
public:
UILabel *m_label;
UIButton *m_ok;
UIButton *m_cancel;
public:
CLASS_PROTOTYPE( UIDialog );
UIDialog();
void FrameInitialized( void );
void LinkCvar( str cvarname );
void SetOKCommand( str command );
void SetCancelCommand( str command );
void SetLabelMaterial( UIReggedMaterial *mat );
void SetOkMaterial( UIReggedMaterial *mat );
void SetCancelMaterial( UIReggedMaterial *mat );
};
#endif

80
code/uilib/uifield.cpp Normal file
View file

@ -0,0 +1,80 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UIField, NULL )
{
{ NULL, NULL }
};
UIField::UIField()
{
// FIXME: stub
}
void UIField::Draw
(
void
)
{
// FIXME: stub
}
qboolean UIField::KeyEvent
(
int key,
unsigned int time
)
{
// FIXME: stub
return qfalse;
}
void UIField::CharEvent
(
int ch
)
{
// FIXME: stub
}
void UIField::UpdateData
(
void
)
{
// FIXME: stub
}
void UIField::Pressed
(
Event *ev
)
{
// FIXME: stub
}

46
code/uilib/uifield.h Normal file
View file

@ -0,0 +1,46 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIFIELD_H__
#define __UIFIELD_H__
class UIField : public UIWidget {
EditField m_edit;
int m_iPreStep;
public:
CLASS_PROTOTYPE( UIField );
private:
void Draw( void );
qboolean KeyEvent( int key, unsigned int time );
void CharEvent( int ch );
public:
UIField();
void UpdateData( void );
void Pressed( Event *ev );
};
#endif

189
code/uilib/uifloatwnd.cpp Normal file
View file

@ -0,0 +1,189 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UIChildSpaceWidget, NULL )
{
{ NULL, NULL }
};
UIChildSpaceWidget::UIChildSpaceWidget()
{
// FIXME: stub
}
qboolean UIChildSpaceWidget::KeyEvent
(
int key,
unsigned int time
)
{
// FIXME: stub
return qfalse;
}
CLASS_DECLARATION( UIWidget, UIFloatingWindow, NULL )
{
{ NULL, NULL }
};
Event UIFloatingWindow::W_ClosePressed;
Event UIFloatingWindow::W_MinimizePressed;
UIFloatingWindow::UIFloatingWindow()
{
// FIXME: stub
}
void UIFloatingWindow::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UIFloatingWindow::FrameInitialized
(
bool bHasDragBar
)
{
// FIXME: stub
}
void UIFloatingWindow::ClosePressed
(
Event *ev
)
{
// FIXME: stub
}
void UIFloatingWindow::MinimizePressed
(
Event *ev
)
{
// FIXME: stub
}
void UIFloatingWindow::Pressed
(
Event *ev
)
{
// FIXME: stub
}
void UIFloatingWindow::Released
(
Event *ev
)
{
// FIXME: stub
}
void UIFloatingWindow::Dragged
(
Event *ev
)
{
// FIXME: stub
}
void UIFloatingWindow::SizeChanged
(
Event *ev
)
{
// FIXME: stub
}
void UIFloatingWindow::OnActivated
(
Event *ev
)
{
// FIXME: stub
}
void UIFloatingWindow::OnDeactivated
(
Event *ev
)
{
// FIXME: stub
}
void UIFloatingWindow::Create
(
UIWidget *parent,
const UIRect2D& rect,
const char *title,
const UColor& bgColor,
const UColor& fgColor
)
{
// FIXME: stub
}
void UIFloatingWindow::Draw
(
void
)
{
// FIXME: stub
}
UIChildSpaceWidget *UIFloatingWindow::getChildSpace
(
void
)
{
// FIXME: stub
return NULL;
}
bool UIFloatingWindow::IsMinimized
(
void
)
{
// FIXME: stub
return false;
}

79
code/uilib/uifloatwnd.h Normal file
View file

@ -0,0 +1,79 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UI_FLOATWND_H__
#define __UI_FLOATWND_H__
class UIChildSpaceWidget : public UIWidget {
public:
CLASS_PROTOTYPE( UIChildSpaceWidget );
public:
UIChildSpaceWidget();
qboolean KeyEvent( int key, unsigned int time );
};
class UIFloatingWindow : public UIWidget {
UIPoint2D m_clickOffset;
bool m_isPressed;
UColor m_titleColor;
UColor m_textColor;
UIChildSpaceWidget *m_childspace;
bool m_minimized;
float m_restoredHeight;
UIPoint2D m_clickpoint;
int m_clicktime;
protected:
UIButton *m_closeButton;
UIButton *m_minimizeButton;
public:
CLASS_PROTOTYPE( UIFloatingWindow );
static Event W_ClosePressed;
static Event W_MinimizePressed;
protected:
void FrameInitialized( void );
void FrameInitialized( bool bHasDragBar );
public:
UIFloatingWindow();
void ClosePressed( Event *ev );
void MinimizePressed( Event *ev );
void Pressed( Event *ev );
void Released( Event *ev );
void Dragged( Event *ev );
void SizeChanged( Event *ev );
void OnActivated( Event *ev );
void OnDeactivated( Event *ev );
void Create( UIWidget *parent, const UIRect2D& rect, const char *title, const UColor& bgColor, const UColor& fgColor );
void Draw( void );
UIChildSpaceWidget *getChildSpace( void );
bool IsMinimized( void );
};
#endif

352
code/uilib/uifont.cpp Normal file
View file

@ -0,0 +1,352 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
UIFont::UIFont()
{
m_font = uii.Rend_LoadFont( "verdana-14" );
if( !m_font ) {
uii.Sys_Error( ERR_DROP, "Couldn't load font Verdana\n" );
}
color = UBlack;
setColor( color );
}
UIFont::UIFont
(
const char *fn
)
{
setFont( fn );
}
void UIFont::Print
(
float x,
float y,
const char *text,
int maxlen,
qboolean bVirtualScreen
)
{
uii.Rend_SetColor( color );
uii.Rend_DrawString( m_font, text, x, y, maxlen, bVirtualScreen );
}
void UIFont::PrintJustified
(
const UIRect2D& rect,
fonthorzjustify_t horz,
fontvertjustify_t vert,
const char *text,
float *vVirtualScale
)
{
float newx, newy;
int textwidth, textheight;
UIRect2D sizedRect;
const char *source;
char *dest;
char string[ 2048 ];
if( vVirtualScale )
{
sizedRect.pos.x = rect.pos.x / vVirtualScale[ 0 ];
sizedRect.pos.y = rect.pos.y / vVirtualScale[ 1 ];
sizedRect.size.width = rect.size.width / vVirtualScale[ 2 ];
sizedRect.size.height = rect.size.height / vVirtualScale[ 3 ];
}
else
{
sizedRect = rect;
}
if( horz == FONT_JUSTHORZ_LEFT && vert == FONT_JUSTVERT_TOP )
{
// no need to justify
Print( sizedRect.pos.x, sizedRect.pos.y, text, -1, vVirtualScale != NULL );
return;
}
textheight = getHeight( text, -1, qfalse );
switch( vert )
{
case FONT_JUSTVERT_TOP:
newy = sizedRect.pos.y;
break;
case FONT_JUSTVERT_CENTER:
newy = ( sizedRect.size.height - textheight ) * 0.5 + sizedRect.pos.y;
break;
case FONT_JUSTVERT_BOTTOM:
newy = sizedRect.pos.y - textheight;
break;
default:
newy = 0;
break;
}
source = text;
while( *source )
{
while( *source == '\n' )
source++;
if( !*source )
return;
dest = string;
do
*dest++ = *source++;
while( *source && *source != '\n' );
*dest = 0;
textwidth = getWidth( string, -1 );
switch( horz )
{
case FONT_JUSTHORZ_CENTER:
newx = ( sizedRect.size.width - textwidth ) * 0.5 + sizedRect.pos.x;
break;
case FONT_JUSTHORZ_LEFT:
newx = sizedRect.pos.x;
break;
case FONT_JUSTHORZ_RIGHT:
newx = sizedRect.pos.x + sizedRect.size.width - textwidth;
break;
default:
newx = 0.0;
break;
}
Print( newx, newy, string, -1, vVirtualScale != NULL );
// expand for newline
newy += getHeight( " ", -1, qfalse );
}
}
void UIFont::setColor
(
UColor col
)
{
color = col;
}
void UIFont::setAlpha
(
float alpha
)
{
color.a = alpha;
}
void UIFont::setFont
(
const char *fontname
)
{
m_font = uii.Rend_LoadFont( fontname );
if( !m_font ) {
uii.Sys_Error( ERR_DROP, "Couldn't load font %s\n", fontname );
}
}
int UIFont::getWidth
(
const char *text,
int maxlen
)
{
return UI_FontStringWidth( m_font, text, maxlen );
}
int UIFont::getCharWidth
(
char ch
)
{
int indirected = m_font->indirection[ 32 ];
if( ch == '\t' )
{
indirected = m_font->indirection[ 32 ];
if( indirected > 255 ) {
Com_Printf( "getCharWidth: no space-character in font!\n" );
return 0;
}
return m_font->locations[ indirected ].size[ 0 ] * 256.0 * 3.0;
}
else
{
indirected = m_font->indirection[ ch ];
if( indirected > 255 ) {
Com_Printf( "getCharWidth: no 0x%02x-character in font!\n", ch );
return 0;
}
return m_font->locations[ indirected ].size[ 0 ] * 256.0;
}
}
int UIFont::getHeight
(
const char *text,
int maxlen,
qboolean bVirtual
)
{
float height;
int i;
if( !m_font ) {
return 0;
}
height = getHeight( bVirtual );
i = 0;
while( text[ i ] )
{
if( maxlen != -1 && i > maxlen ) {
break;
}
if( text[ i ] == '\n' )
{
height += getHeight( bVirtual );
}
}
return height;
}
int UIFont::getHeight
(
qboolean bVirtual
)
{
if( bVirtual )
{
if( m_font )
{
return ( m_font->height * uid.vidHeight / 480.0 );
}
else
{
return ( 16.0 * uid.vidHeight / 480.0 );
}
}
else
{
if( m_font )
{
return m_font->height;
}
else
{
return 16;
}
}
}
int UI_FontStringWidth
(
fontheader_t *pFont,
const char *pszString,
int iMaxLen
)
{
float widths = 0.0;
float maxwidths = 0.0;
int indirected;
int i;
if( !pFont ) {
return 0;
}
if( iMaxLen == -1 ) {
iMaxLen = strlen( pszString ) + 1;
}
for( i = 0; i < iMaxLen; i++ )
{
unsigned char c = pszString[ i ];
if( c == 0 )
{
break;
}
else if( c == '\t' )
{
indirected = pFont->indirection[ 32 ];
if( indirected > 255 ) {
Com_Printf( "UIFont::getWidth: no space-character in font!\n" );
continue;
} else {
widths += pFont->locations[ indirected ].size[ 0 ] * 3.0;
}
}
else if( c == '\n' )
{
widths = 0.0;
}
else
{
indirected = pFont->indirection[ c ];
if( indirected > 255 ) {
Com_Printf( "UIFont::getWidth: no 0x%02x-character in font!\n", c );
continue;
} else {
widths += pFont->locations[ indirected ].size[ 0 ];
}
}
if( maxwidths < widths ) {
maxwidths = widths;
}
}
return maxwidths * 256.0;
}

54
code/uilib/uifont.h Normal file
View file

@ -0,0 +1,54 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIFONT_H__
#define __UIFONT_H__
class UIRect2D;
typedef enum { FONT_JUSTHORZ_CENTER, FONT_JUSTHORZ_LEFT, FONT_JUSTHORZ_RIGHT } fonthorzjustify_t;
typedef enum { FONT_JUSTVERT_TOP, FONT_JUSTVERT_CENTER, FONT_JUSTVERT_BOTTOM } fontvertjustify_t;
class UIFont {
protected:
unsigned int m_listbase;
UColor color;
fontheader_t *m_font;
public:
UIFont();
UIFont( const char *fn );
void Print( float x, float y, const char *text, int maxlen, qboolean bVirtualScreen );
void PrintJustified( const UIRect2D& rect, fonthorzjustify_t horz, fontvertjustify_t vert, const char *text, float *vVirtualScale );
void setColor( UColor col );
void setAlpha( float alpha );
void setFont( const char *fontname );
int getWidth( const char *text, int maxlen );
int getCharWidth( char ch );
int getHeight( const char *text, int maxlen, qboolean bVirtual );
int getHeight( qboolean bVirtual );
};
int UI_FontStringWidth( fontheader_t *pFont, const char *pszString, int iMaxLen );
#endif

View file

@ -0,0 +1,37 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UILanGameList, UIGlobalGameList, NULL )
{
{ NULL, NULL }
};
void UIGlobalGameList::UpdateServers
(
void
)
{
// FIXME: stub
}

View file

@ -0,0 +1,37 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIGLOBALGAMELIST_H__
#define __UIGLOBALGAMELIST_H__
#include "uilangamelist.h"
class UIGlobalGameList : public UILanGameList {
public:
CLASS_PROTOTYPE( UIGlobalGameList );
public:
virtual void UpdateServers();
};
#endif

View file

@ -0,0 +1,230 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UIHorizScroll, NULL )
{
{ NULL, NULL }
};
UIHorizScroll::UIHorizScroll()
{
// FIXME: stub
}
int UIHorizScroll::getItemFromWidth
(
float height
)
{
// FIXME: stub
return 0;
}
bool UIHorizScroll::isEnoughItems
(
void
)
{
// FIXME: stub
return false;
}
void UIHorizScroll::Draw
(
void
)
{
// FIXME: stub
}
void UIHorizScroll::DrawArrow
(
float top,
const char *text,
bool pressed
)
{
// FIXME: stub
}
void UIHorizScroll::DrawThumb
(
void
)
{
// FIXME: stub
}
void UIHorizScroll::MouseDown
(
Event *ev
)
{
// FIXME: stub
}
void UIHorizScroll::MouseUp
(
Event *ev
)
{
// FIXME: stub
}
void UIHorizScroll::MouseDragged
(
Event *ev
)
{
// FIXME: stub
}
void UIHorizScroll::MouseEnter
(
Event *ev
)
{
// FIXME: stub
}
void UIHorizScroll::MouseLeave
(
Event *ev
)
{
// FIXME: stub
}
void UIHorizScroll::Scroll
(
Event *ev
)
{
// FIXME: stub
}
bool UIHorizScroll::AttemptScrollTo
(
int to
)
{
// FIXME: stub
return false;
}
void UIHorizScroll::setNumItems
(
int i
)
{
// FIXME: stub
}
void UIHorizScroll::setPageWidth
(
int i
)
{
// FIXME: stub
}
void UIHorizScroll::setTopItem
(
int i
)
{
// FIXME: stub
}
int UIHorizScroll::getTopItem
(
void
)
{
// FIXME: stub
return 0;
}
int UIHorizScroll::getPageWidth
(
void
)
{
// FIXME: stub
return 0;
}
int UIHorizScroll::getNumItems
(
void
)
{
// FIXME: stub
return 0;
}
void UIHorizScroll::setThumbColor
(
const UColor& thumb
)
{
// FIXME: stub
}
void UIHorizScroll::setSolidBorderColor
(
const UColor& col
)
{
// FIXME: stub
}
void UIHorizScroll::InitFrameAlignRight
(
UIWidget *parent
)
{
// FIXME: stub
}

View file

@ -0,0 +1,77 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIHORIZSCROLL_H__
#define __UIHORIZSCROLL_H__
typedef enum { VS_NONE, VS_UP_ARROW, VS_DOWN_ARROW, VS_THUMB, VS_PAGE_DOWN, VS_PAGE_UP } whatspressed;
class UIHorizScroll : public UIWidget {
protected:
int m_numitems;
int m_pagewidth;
int m_topitem;
UIFont m_marlett;
whatspressed m_pressed;
UIRect2D thumbRect;
struct {
int itemOffset;
int orgItem;
} m_dragThumbState;
bool m_frameinitted;
UColor m_thumbcolor;
UColor m_solidbordercolor;
public:
CLASS_PROTOTYPE( UIHorizScroll );
protected:
int getItemFromWidth( float height );
bool isEnoughItems( void );
public:
UIHorizScroll();
void Draw( void );
void DrawArrow( float top, const char *text, bool pressed );
void DrawThumb();
void MouseDown( Event *ev );
void MouseUp( Event *ev );
void MouseDragged( Event *ev );
void MouseEnter( Event *ev );
void MouseLeave( Event *ev );
void Scroll( Event *ev );
bool AttemptScrollTo( int to );
void setNumItems( int i );
void setPageWidth( int i );
void setTopItem( int i );
int getTopItem( void );
int getPageWidth( void );
int getNumItems( void );
void setThumbColor( const UColor& thumb );
void setSolidBorderColor( const UColor& col );
void InitFrameAlignRight( UIWidget *parent );
};
#endif

253
code/uilib/uilabel.cpp Normal file
View file

@ -0,0 +1,253 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
#include <localization.h>
Event EV_UILabel_LinkString
(
"linkstring",
EV_DEFAULT,
"is",
"value string",
"Creates a link from the specified value to a string. "
"Use this if you want the label to display a string different from the value of the cvar"
);
Event EV_UILabel_LinkCvarToShader
(
"linkcvartoshader",
EV_DEFAULT,
NULL,
NULL,
"Links the label's cvar to its shader"
);
CLASS_DECLARATION( UIWidget, UILabel, NULL )
{
{ &W_MouseEntered, &UILabel::MouseEntered },
{ &W_MouseExited, &UILabel::MouseExited },
{ &EV_UILabel_LinkString, &UILabel::LinkString },
{ &EV_UILabel_LinkCvarToShader, &UILabel::SetLinkCvarToShader },
{ &EV_Layout_Shader, &UILabel::LabelLayoutShader },
{ &EV_Layout_TileShader, &UILabel::LabelLayoutTileShader },
{ NULL, NULL }
};
UILabel::UILabel()
{
AllowActivate( false );
m_bLinkCvarToShader = false;
}
void UILabel::MouseEntered
(
Event *ev
)
{
SetHovermaterialActive( true );
}
void UILabel::MouseExited
(
Event *ev
)
{
SetHovermaterialActive( false );
SetPressedmaterialActive( false );
}
void UILabel::LinkString
(
Event *ev
)
{
linkstring *ls;
str value;
str string;
value = ev->GetString( 1 );
string = ev->GetString( 2 );
ls = new linkstring( value, string );
m_linkstrings.AddObject( ls );
}
int UILabel::FindLinkString
(
str val
)
{
int i;
for( i = 1; i <= m_linkstrings.NumObjects(); i++ )
{
if( val == m_linkstrings.ObjectAt( i )->value )
return i;
}
return 0;
}
void UILabel::LabelLayoutShader
(
Event *ev
)
{
m_sCurrentShaderName = ev->GetString( 1 );
setMaterial( uWinMan.RegisterShader( m_sCurrentShaderName ) );
m_flags &= ~WF_TILESHADER;
}
void UILabel::LabelLayoutTileShader
(
Event *ev
)
{
m_sCurrentShaderName = ev->GetString( 1 );
setMaterial( uWinMan.RegisterShader( m_sCurrentShaderName ) );
m_flags |= WF_TILESHADER;
}
void UILabel::SetLinkCvarToShader
(
Event *ev
)
{
m_bLinkCvarToShader = true;
}
void UILabel::SetLabel
(
str lab
)
{
label = lab;
}
void UILabel::Draw
(
void
)
{
const char *string;
str val;
if( m_cvarname.length() )
{
string = uii.Cvar_GetString( m_cvarname, "" );
if( m_linkstrings.NumObjects() )
{
cvar_t *cvar = UI_FindCvar( m_cvarname );
if( cvar )
{
int ret;
if( cvar->latchedString )
val = cvar->latchedString;
else
val = cvar->string;
ret = FindLinkString( val );
if( ret )
{
string = m_linkstrings.ObjectAt( ret )->value;
}
}
}
if( m_bLinkCvarToShader )
{
if( str::icmp( m_sCurrentShaderName, string ) )
{
m_sCurrentShaderName = string;
setMaterial( uWinMan.RegisterShader( m_sCurrentShaderName ) );
m_material->ReregisterMaterial();
if( !m_material->GetMaterial() )
{
setMaterial( NULL );
}
}
if( label.length() )
{
string = label;
}
else if( m_title.length() )
{
string = m_title;
}
else
{
string = "";
}
}
}
else
{
if( label.length() )
{
string = label;
}
else if( m_title.length() )
{
string = m_title;
}
else
{
string = "";
}
}
if( *string )
{
float nr, ng, nb;
nr = m_foreground_color.r;
ng = m_foreground_color.g;
nb = m_foreground_color.b;
m_font->setColor( UColor( nr, ng, nb, m_foreground_color.a * m_local_alpha ) );
// print the text
m_font->PrintJustified( getClientFrame(),
m_iFontAlignmentHorizontal,
m_iFontAlignmentVertical,
Sys_LV_CL_ConvertString( string ),
m_bVirtual ? m_vVirtualScale : NULL );
}
}

72
code/uilib/uilabel.h Normal file
View file

@ -0,0 +1,72 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UILABEL_H__
#define __UILABEL_H__
class linkstring {
public:
str value;
str string;
linkstring( str value, str string );
};
inline
linkstring::linkstring
(
str value,
str string
)
{
this->value = value;
this->string = string;
}
class UILabel : public UIWidget {
str label;
Container<linkstring *> m_linkstrings;
qboolean m_bLinkCvarToShader;
str m_sCurrentShaderName;
public:
CLASS_PROTOTYPE( UILabel );
private:
void MouseEntered( Event *ev );
void MouseExited( Event *ev );
void LinkString( Event *ev );
int FindLinkString( str val );
void LabelLayoutShader( Event *ev );
void LabelLayoutTileShader( Event *ev );
void SetLinkCvarToShader( Event *ev );
public:
UILabel();
void SetLabel( str lab );
void Draw( void );
};
#endif

View file

@ -0,0 +1,249 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UILanGameList, NULL )
{
{ NULL, NULL }
};
UILanGameList::UILanGameList()
{
// FIXME: stub
}
void UILanGameList::CreateServerWidgets
(
void
)
{
// FIXME: stub
}
void UILanGameList::DestroyServerWidgets
(
void
)
{
// FIXME: stub
}
void UILanGameList::RepositionServerWidgets
(
void
)
{
// FIXME: stub
}
void UILanGameList::DrawNoServers
(
UIRect2D frame
)
{
// FIXME: stub
}
void UILanGameList::AddColumn
(
str sName,
UIReggedMaterial *pMaterial,
int iWidth,
Container<str> *csEntries
)
{
// FIXME: stub
}
void UILanGameList::AddNoServer
(
void
)
{
// FIXME: stub
}
void UILanGameList::UpdateServers
(
void
)
{
// FIXME: stub
}
void UILanGameList::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UILanGameList::EventScanNetwork
(
Event *ev
)
{
// FIXME: stub
}
void UILanGameList::EventScaningNetwork
(
Event *ev
)
{
// FIXME: stub
}
bool UILanGameList::isDying
(
void
)
{
// FIXME: stub
return false;
}
void UILanGameList::Draw
(
void
)
{
// FIXME: stub
}
qboolean UILanGameList::KeyEvent
(
int key,
unsigned int time
)
{
// FIXME: stub
return qfalse;
}
void UILanGameList::Highlight
(
UIWidget *wid
)
{
// FIXME: stub
}
void UILanGameList::Connect
(
void
)
{
// FIXME: stub
}
void UILanGameList::EventConnect
(
Event *ev
)
{
// FIXME: stub
}
void UILanGameList::PlayEnterSound
(
void
)
{
// FIXME: stub
}
qboolean UILanGameList::SetActiveRow
(
UIWidget *w
)
{
// FIXME: stub
return qfalse;
}
void UILanGameList::Realign
(
void
)
{
// FIXME: stub
}
CLASS_DECLARATION( UILabel, UILanGameListLabel, NULL )
{
{ NULL, NULL }
};
UILanGameListLabel::UILanGameListLabel()
{
}
UILanGameListLabel::UILanGameListLabel
(
UILanGameList *list
)
{
}
void UILanGameListLabel::Pressed
(
Event *ev
)
{
}
void UILanGameListLabel::Unpressed
(
Event *ev
)
{
}

View file

@ -0,0 +1,90 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UILANGAMELIST_H__
#define __UILANGAMELIST_H__
class UILanGameList : public UIWidget {
bool m_created;
UIVertScroll *m_Vscroll;
class UIHorizScroll *m_Hscroll;
UIReggedMaterial *m_noservers_mat;
UILabel *m_noservers_wid;
UIReggedMaterial *m_fill_mat;
Container<UIWidget *> m_widgetlist;
Container<UIWidget *> m_titlewidgets;
Container<UIWidget *> m_miscwidgets;
int m_activerow;
int m_activeitem;
Container<serverInfo_t *> m_servers;
int m_iNumColumns;
int m_iPrevNumServers;
int m_iCurrNumServers;
float m_fCurColumnWidth;
public:
CLASS_PROTOTYPE( UILanGameList );
private:
void CreateServerWidgets( void );
void DestroyServerWidgets( void );
void RepositionServerWidgets( void );
void DrawNoServers( UIRect2D frame );
void AddColumn( str sName, UIReggedMaterial *pMaterial, int iWidth, Container<str> *csEntries );
void AddNoServer( void );
virtual void UpdateServers( void );
protected:
void FrameInitialized( void );
void EventScanNetwork( Event *ev );
void EventScaningNetwork( Event *ev );
public:
UILanGameList();
bool isDying( void );
void Draw();
qboolean KeyEvent( int key, unsigned int time );
void Highlight( UIWidget *wid );
void Connect( void );
void EventConnect( Event *ev );
void PlayEnterSound( void );
qboolean SetActiveRow( UIWidget *w );
void Realign( void );
};
class UILanGameListLabel : public UILabel {
int m_iLastPressedTime;
UILanGameList *m_list;
public:
CLASS_PROTOTYPE( UILanGameListLabel );
UILanGameListLabel();
UILanGameListLabel( UILanGameList *list );
void Pressed( Event *ev );
void Unpressed( Event *ev );
};
#endif

296
code/uilib/uilayout.cpp Normal file
View file

@ -0,0 +1,296 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
Event EV_Layout_Menu
(
"menu",
EV_DEFAULT,
"sffsF",
"name width height direction motion_time",
"Sets up the layout of the menu."
);
CLASS_DECLARATION( Listener, UILayout, NULL )
{
{ &EV_Layout_Menu, &UILayout::CreateWidgetContainer },
{ NULL, NULL }
};
UILayout::UILayout()
{
BogusFunction();
m_script = NULL;
m_filename = NULL;
}
UILayout::UILayout
(
const char *filename
)
{
BogusFunction();
m_script = NULL;
m_filename = filename;
if( filename )
Load( filename, true );
}
void UILayout::BogusFunction
(
void
)
{
}
void UILayout::CreateWidgetContainer
(
Event *ev
)
{
str name;
str direction;
float w, h;
name = ev->GetString( 1 );
if( !name.length() )
return;
w = ev->GetFloat( 2 );
h = ev->GetFloat( 3 );
direction = ev->GetString( 4 );
m_currentcontainer = new UIWidgetContainer;
m_currentcontainer->setName( name );
if( !stricmp( direction, "from_bottom" ) )
{
m_currentcontainer->setDirection( D_FROM_BOTTOM );
}
else if( !stricmp( direction, "from_top" ) )
{
m_currentcontainer->setDirection( D_FROM_TOP );
}
else if( !stricmp( direction, "from_left" ) )
{
m_currentcontainer->setDirection( D_FROM_LEFT );
}
else if( !stricmp( direction, "from_right" ) )
{
m_currentcontainer->setDirection( D_FROM_RIGHT );
}
if( ev->NumArgs() > 4 )
{
m_currentcontainer->setMotionTime( ev->GetFloat( 5 ) );
}
m_currentcontainer->setAlwaysOnBottom( true );
m_currentcontainer->InitFrame( NULL, 0, 0, w, h );
m_currentcontainer->m_layout = this;
m_currentwidget = m_currentcontainer;
}
void UILayout::ProcessCommands
(
bool bFullLoad
)
{
const char *token;
Event *ev;
UIWidget *widget;
str postinclude;
try
{
while( m_script->TokenAvailable( true ) )
{
token = m_script->GetToken( true );
if( !strcmp( token, "end." ) )
{
break;
}
else if( !strcmp( token, "include" ) )
{
if( m_script->TokenAvailable( false ) )
{
m_scriptstack.Push( m_script );
Load( m_script->GetToken( false ), bFullLoad );
m_script = m_scriptstack.Pop();
}
}
else if( !strcmp( token, "postinclude" ) )
{
if( m_script->TokenAvailable( false ) )
{
token = m_script->GetToken( false );
postinclude = token;
}
}
else if( !strcmp( token, "resource" ) )
{
ClassDef *cls;
str cl;
const char *newname;
token = m_script->GetToken( true );
// find the class resource
newname = uii.Client_TranslateWidgetName( token );
if( !newname ) newname = token;
cl = "UI";
cl += newname;
cls = getClass( cl );
assert( cls );
if( !cls )
{
Com_Printf( "Failed to find resource type '%s'\n", token );
break;
}
widget = ( UIWidget * )cls->newInstance();
token = m_script->GetToken( true );
if( *token == '{' )
{
widget->InitFrame( m_currentcontainer, 0, 0, 128, 64, -1, "verdana-12" );
if( widget->m_bVirtual )
{
ev = new Event( EV_Layout_VirtualRes );
ev->AddInteger( 1 );
widget->ProcessEvent( ev );
}
token = m_script->GetToken( true );
while( 1 )
{
if( !strcmp( token, "}" ) )
{
break;
}
if( widget->ValidEvent( token ) )
{
ev = new Event( token );
while( m_script->TokenAvailable( false ) )
{
token = m_script->GetToken( false );
ev->AddToken( token );
}
widget->ProcessEvent( ev );
}
if( !m_script->TokenAvailable( true ) )
break;
token = m_script->GetToken( true );
}
}
}
else
{
if( ValidEvent( token ) )
{
ev = new Event( token );
while( m_script->TokenAvailable( false ) )
{
token = m_script->GetToken( false );
ev->AddToken( token );
}
ProcessEvent( ev );
}
else if( m_currentwidget && m_currentwidget->ValidEvent( token ) )
{
ev = new Event( token );
while( m_script->TokenAvailable( false ) )
{
token = m_script->GetToken( false );
ev->AddToken( token );
}
m_currentwidget->ProcessEvent( ev );
}
}
}
}
catch( ScriptException& exc )
{
uii.Sys_Printf( "UI EXCEPTION : %s\n", exc.string.c_str() );
}
// process post-includes
if( postinclude.length() )
{
m_scriptstack.Push( m_script );
Load( postinclude, bFullLoad );
m_script = m_scriptstack.Pop();
}
}
void UILayout::Load
(
const char *filename,
bool bFullLoad
)
{
m_bLoaded = true;
m_script = new Script;
m_script->LoadFile( filename );
ProcessCommands( bFullLoad );
m_bLoaded = bFullLoad;
delete m_script;
m_script = NULL;
}
int UILayout::ForceLoad
(
void
)
{
if( m_bLoaded )
return 0;
Load( m_filename, true );
return true;
}

52
code/uilib/uilayout.h Normal file
View file

@ -0,0 +1,52 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UILAYOUT_H__
#define __UILAYOUT_H__
class Script;
class UILayout : public Listener {
str m_filename;
Script *m_script;
Stack<Script *> m_scriptstack;
UIWidgetContainer *m_currentcontainer;
UIWidget *m_currentwidget;
bool m_bLoaded;
public:
CLASS_PROTOTYPE( UILayout );
private:
void BogusFunction( void );
void CreateWidgetContainer( Event *ev );
void ProcessCommands( bool bFullLoad );
public:
UILayout();
UILayout( const char *filename );
void Load( const char *filename, bool bFullLoad );
int ForceLoad( void );
};
#endif

160
code/uilib/uilist.cpp Normal file
View file

@ -0,0 +1,160 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UIList, NULL )
{
{ NULL, NULL }
};
UIList::UIList()
{
// FIXME: stub
}
void UIList::Draw
(
void
)
{
// FIXME: stub
}
qboolean UIList::KeyEvent
(
int key,
unsigned int time
)
{
// FIXME: stub
return qfalse;
}
void UIList::CharEvent
(
int ch
)
{
// FIXME: stub
}
void UIList::Pressed
(
Event *ev
)
{
// FIXME: stub
}
void UIList::Released
(
Event *ev
)
{
// FIXME: stub
}
void UIList::ScrollNext
(
void
)
{
// FIXME: stub
}
void UIList::ScrollPrev
(
void
)
{
// FIXME: stub
}
void UIList::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UIList::LayoutAddListItem
(
Event *ev
)
{
// FIXME: stub
}
void UIList::AddItem
(
str item,
str alias
)
{
// FIXME: stub
}
void UIList::UpdateUIElement
(
void
)
{
// FIXME: stub
}
void UIList::UpdateData
(
void
)
{
// FIXME: stub
}
CLASS_DECLARATION( UIList, UIListIndex, NULL )
{
{ NULL, NULL }
};
qboolean UIListIndex::KeyEvent
(
int key,
unsigned int time
)
{
// FIXME: stub
return qfalse;
}

74
code/uilib/uilist.h Normal file
View file

@ -0,0 +1,74 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UILIST_H__
#define __UILIST_H__
class UIListItem {
public:
str itemname;
str itemalias;
};
class UIList : public UIWidget {
protected:
Container<UIListItem *> m_itemlist;
int m_currentItem;
float m_arrow_width;
UIRect2D *m_next_arrow_region;
UIRect2D *m_prev_arrow_region;
bool m_depressed;
bool m_held;
UIReggedMaterial *m_prev_arrow;
UIReggedMaterial *m_next_arrow;
bool m_prev_arrow_depressed;
bool m_next_arrow_depressed;
public:
CLASS_PROTOTYPE( UIList );
protected:
void Draw( void );
qboolean KeyEvent( int key, unsigned int time );
void CharEvent( int ch );
void Pressed( Event *ev );
void Released( Event *ev );
void ScrollNext( void );
void ScrollPrev( void );
void FrameInitialized( void );
void LayoutAddListItem( Event *ev );
void AddItem( str item, str alias );
public:
UIList();
void UpdateUIElement( void );
void UpdateData( void );
};
class UIListIndex : public UIList {
public:
CLASS_PROTOTYPE( UIListIndex );
qboolean KeyEvent( int key, unsigned int time );
};
#endif /* __UILIST_H__ */

284
code/uilib/uilistbox.cpp Normal file
View file

@ -0,0 +1,284 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UIListBase, NULL )
{
{ NULL, NULL }
};
UIListBase::UIListBase()
{
// FIXME: stub
}
void UIListBase::TrySelectItem
(
int which
)
{
// FIXME: stub
}
qboolean UIListBase::KeyEvent
(
int key,
unsigned int time
)
{
// FIXME: stub
return qfalse;
}
void UIListBase::FrameInitialized
(
void
)
{
// FIXME: stub
}
int UIListBase::getCurrentItem
(
void
)
{
// FIXME: stub
return 0;
}
int UIListBase::getNumItems
(
void
)
{
// FIXME: stub
return 0;
}
void UIListBase::DeleteAllItems
(
void
)
{
// FIXME: stub
}
void UIListBase::DeleteItem
(
int which
)
{
// FIXME: stub
}
UIVertScroll *UIListBase::GetScrollBar
(
void
)
{
// FIXME: stub
return NULL;
}
void UIListBase::SetUseScrollBar
(
qboolean bUse
)
{
// FIXME: stub
}
ListItem::ListItem()
{
// FIXME: stub
}
ListItem::ListItem
(
str string,
int index,
str command
)
{
// FIXME: stub
}
CLASS_DECLARATION( UIListBase, UIListBox, NULL )
{
{ NULL, NULL }
};
UIListBox::UIListBox()
{
// FIXME: stub
}
void UIListBox::Draw
(
void
)
{
// FIXME: stub
}
void UIListBox::MousePressed
(
Event *ev
)
{
// FIXME: stub
}
void UIListBox::MouseReleased
(
Event *ev
)
{
// FIXME: stub
}
void UIListBox::DeleteAllItems
(
Event *ev
)
{
// FIXME: stub
}
void UIListBox::SetListFont
(
Event *ev
)
{
// FIXME: stub
}
void UIListBox::TrySelectItem
(
int which
)
{
// FIXME: stub
}
void UIListBox::AddItem
(
const char *item,
const char *command
)
{
// FIXME: stub
}
void UIListBox::AddItem
(
int index,
const char *command
)
{
// FIXME: stub
}
void UIListBox::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UIListBox::LayoutAddListItem
(
Event *ev
)
{
// FIXME: stub
}
void UIListBox::LayoutAddConfigstringListItem
(
Event *ev
)
{
// FIXME: stub
}
str UIListBox::getItemText
(
int which
)
{
// FIXME: stub
return "";
}
int UIListBox::getNumItems
(
void
)
{
// FIXME: stub
return 0;
}
void UIListBox::DeleteAllItems
(
void
)
{
// FIXME: stub
}
void UIListBox::DeleteItem
(
int which
)
{
// FIXME: stub
}

95
code/uilib/uilistbox.h Normal file
View file

@ -0,0 +1,95 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UILISTBOX_H__
#define __UILISTBOX_H__
class UIListBase : public UIWidget {
protected:
int m_currentItem;
class UIVertScroll *m_vertscroll;
qboolean m_bUseVertScroll;
public:
CLASS_PROTOTYPE( UIListBase );
protected:
virtual void TrySelectItem( int which );
qboolean KeyEvent( int key, unsigned int time );
public:
UIListBase();
void FrameInitialized( void );
int getCurrentItem( void );
virtual int getNumItems( void );
virtual void DeleteAllItems( void );
virtual void DeleteItem( int which );
UIVertScroll *GetScrollBar( void );
void SetUseScrollBar( qboolean bUse );
};
typedef class UIListBase UIListBase;
class ListItem : public Class {
public:
str string;
str command;
int index;
public:
ListItem();
ListItem( str string, int index, str command );
};
class UIListBox : public UIListBase {
protected:
Container<ListItem *> m_itemlist;
struct {
int time;
int selected;
UIPoint2D point;
} m_clickState;
public:
CLASS_PROTOTYPE( UIListBox );
protected:
void Draw( void );
void MousePressed( Event *ev );
void MouseReleased( Event *ev );
void DeleteAllItems( Event *ev );
void SetListFont( Event *ev );
void TrySelectItem( int which );
public:
UIListBox();
void AddItem( const char *item, const char *command );
void AddItem( int index, const char *command );
void FrameInitialized( void );
void LayoutAddListItem( Event *ev );
void LayoutAddConfigstringListItem( Event *ev );
str getItemText( int which );
int getNumItems( void );
void DeleteAllItems( void );
void DeleteItem( int which );
};
#endif /* __UILISTBOX_H__ */

343
code/uilib/uilistctrl.cpp Normal file
View file

@ -0,0 +1,343 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
griditemtype_t UIListCtrlItem::getListItemType
(
int which
) const
{
// FIXME: stub
return TYPE_STRING;
}
str UIListCtrlItem::getListItemString
(
int which
) const
{
// FIXME: stub
return "";
}
int UIListCtrlItem::getListItemValue
(
int which
) const
{
// FIXME: stub
return 0;
}
void UIListCtrlItem::DrawListItem
(
int,
UIRect2D const &,
bool, UIFont *
)
{
// FIXME: stub
}
qboolean UIListCtrlItem::IsHeaderEntry
(
void
) const
{
// FIXME: stub
return qfalse;
}
CLASS_DECLARATION( UIListBase, UIListCtrl, NULL )
{
{ NULL, NULL }
};
UIListCtrl::UIListCtrl()
{
// FIXME: stub
}
int UIListCtrl::StringCompareFunction
(
const UIListCtrlItem *i1,
const UIListCtrlItem *i2,
int columnname
)
{
// FIXME: stub
return 0;
}
int UIListCtrl::StringNumberCompareFunction
(
const UIListCtrlItem *i1,
const UIListCtrlItem *i2,
int columnname
)
{
// FIXME: stub
return 0;
}
int UIListCtrl::QsortCompare
(
const void *e1,
const void *e2
)
{
// FIXME: stub
return 0;
}
void UIListCtrl::Draw
(
void
)
{
// FIXME: stub
}
int UIListCtrl::getHeaderHeight
(
void
)
{
// FIXME: stub
return 0;
}
void UIListCtrl::MousePressed
(
Event *ev
)
{
// FIXME: stub
}
void UIListCtrl::MouseDragged
(
Event *ev
)
{
// FIXME: stub
}
void UIListCtrl::MouseReleased
(
Event *ev
)
{
// FIXME: stub
}
void UIListCtrl::MouseEntered
(
Event *ev
)
{
// FIXME: stub
}
void UIListCtrl::OnSizeChanged
(
Event *ev
)
{
// FIXME: stub
}
void UIListCtrl::DrawColumns
(
void
)
{
// FIXME: stub
}
void UIListCtrl::DrawContent
(
void
)
{
// FIXME: stub
}
void UIListCtrl::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UIListCtrl::SetDrawHeader
(
qboolean bDrawHeader
)
{
// FIXME: stub
}
void UIListCtrl::AddItem
(
UIListCtrlItem *item
)
{
// FIXME: stub
}
void UIListCtrl::InsertItem
(
UIListCtrlItem *item, int where
)
{
// FIXME: stub
}
int UIListCtrl::FindItem
(
UIListCtrlItem *item
)
{
// FIXME: stub
return 0;
}
UIListCtrlItem *UIListCtrl::GetItem
(
int item
)
{
// FIXME: stub
return NULL;
}
void UIListCtrl::AddColumn
(
str title,
int name,
int width,
bool numeric,
bool reverse_sort
)
{
// FIXME: stub
}
void UIListCtrl::RemoveAllColumns
(
void
)
{
// FIXME: stub
}
int UIListCtrl::getNumItems
(
void
)
{
// FIXME: stub
return 0;
}
void UIListCtrl::DeleteAllItems
(
void
)
{
// FIXME: stub
}
void UIListCtrl::DeleteItem
(
int which
)
{
// FIXME: stub
}
void UIListCtrl::SortByColumn
(
int column
)
{
// FIXME: stub
}
void UIListCtrl::SortByLastSortColumn
(
void
)
{
// FIXME: stub
}
void UIListCtrl::setCompareFunction
(
int( *func ) ( const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname )
)
{
// FIXME: stub
}
void UIListCtrl::setHeaderFont
(
const char *name
)
{
// FIXME: stub
}

107
code/uilib/uilistctrl.h Normal file
View file

@ -0,0 +1,107 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UILISTCTRL_H__
#define __UILISTCTRL_H__
typedef enum { TYPE_STRING, TYPE_OWNERDRAW } griditemtype_t;
class UIListCtrlItem {
public:
virtual griditemtype_t getListItemType( int which ) const;
virtual str getListItemString( int which ) const;
virtual int getListItemValue( int which ) const;
virtual void DrawListItem( int iColumn, const UIRect2D &drawRect, bool bSelected, UIFont *pFont );
virtual qboolean IsHeaderEntry( void ) const;
};
typedef struct m_clickState_s {
int time;
int selected;
UIPoint2D point;
} m_clickState_t;
class UIListCtrl : public UIListBase {
public:
struct columndef_t {
str title;
int name;
int width;
bool numeric;
bool reverse_sort;
};
protected:
static bool s_qsortreverse;
static int s_qsortcolumn;
static class UIListCtrl *s_qsortobject;
int m_iLastSortColumn;
class UIFont *m_headerfont;
Container<UIListCtrlItem *> m_itemlist;
Container<UIListCtrl::columndef_t> m_columnlist;
qboolean m_bDrawHeader;
struct {
int column;
int min;
} m_sizestate;
m_clickState_s m_clickState;
int( *m_comparefunction ) (/* unknown */ );
public:
CLASS_PROTOTYPE( UIListCtrl );
protected:
static int StringCompareFunction( const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname );
static int StringNumberCompareFunction( const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname );
static int QsortCompare( const void *e1, const void *e2 );
void Draw( void );
int getHeaderHeight( void );
void MousePressed( Event *ev );
void MouseDragged( Event *ev );
void MouseReleased( Event *ev );
void MouseEntered( Event *ev );
void OnSizeChanged( Event *ev );
void DrawColumns( void );
void DrawContent( void );
public:
UIListCtrl();
void FrameInitialized( void );
void SetDrawHeader( qboolean bDrawHeader );
void AddItem( UIListCtrlItem *item );
void InsertItem( UIListCtrlItem *item, int where );
int FindItem( UIListCtrlItem *item );
UIListCtrlItem *GetItem( int item );
void AddColumn( str title, int name, int width, bool numeric, bool reverse_sort );
void RemoveAllColumns( void );
int getNumItems( void );
void DeleteAllItems( void );
void DeleteItem( int which );
virtual void SortByColumn( int column );
void SortByLastSortColumn( void );
void setCompareFunction( int( *func ) ( const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname ) );
void setHeaderFont( const char *name );
};
#endif

987
code/uilib/uimenu.cpp Normal file
View file

@ -0,0 +1,987 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
MenuManager menuManager;
Event EV_PushMenu
(
"pushmenu",
EV_DEFAULT,
"s",
"menuname",
"Pushes the menu on the stack"
);
Event EV_LockMenus
(
"lock",
EV_DEFAULT,
NULL,
NULL,
"Lock out the menu from receiving input"
);
Event EV_UnlockMenus
(
"unlock",
EV_DEFAULT,
NULL,
NULL,
"Unlock the menu from receiving input"
);
Event EV_ShowMenu
(
"showmenu",
EV_DEFAULT,
"B",
"activate",
"Shows the menu."
);
Event EV_HideMenu
(
"hidemenu",
EV_DEFAULT,
NULL,
NULL,
"Hides the menu."
);
CLASS_DECLARATION( Listener, Menu, NULL )
{
{ &EV_HideMenu, &Menu::HideMenu },
{ &EV_ShowMenu, &Menu::ShowMenu },
{ NULL, NULL }
};
Menu::Menu()
{
menuManager.AddMenu( this );
m_fullscreen = qfalse;
}
Menu::Menu
(
str name
)
{
setName( name );
m_fullscreen = qfalse;
menuManager.AddMenu( this );
}
void Menu::AddMenuItem
(
UIWidget *item
)
{
m_itemlist.AddObject( item );
// add all item's children
for( int i = 1; i <= item->m_children.NumObjects(); i++ )
{
m_itemlist.AddObject( item->m_children.ObjectAt( i ) );
}
}
void Menu::DeleteMenuItem
(
UIWidget *item
)
{
// remove all item's children
for( int i = item->m_children.NumObjects(); i > 0; i-- )
{
m_itemlist.RemoveObject( item->m_children.ObjectAt( i ) );
}
m_itemlist.RemoveObject( item );
}
void Menu::setName
(
str name
)
{
m_name = name;
}
void Menu::ShowMenu
(
Event *ev
)
{
qboolean activate;
int i;
int n;
n = m_itemlist.NumObjects();
for( i = 1; i <= n; i++ )
{
UIWidget *wid = m_itemlist.ObjectAt( i );
UIWidgetContainer *widcon = ( UIWidgetContainer * )wid;
if( wid->isSubclassOf( UIWidgetContainer ) && widcon->m_layout )
{
widcon->m_layout->ForceLoad();
}
if( wid->isEnabled() )
{
wid->setShow( true );
wid->ResetMotion( MOTION_IN );
wid->ExecuteShowCommands();
}
}
if( ev && ev->NumArgs() > 0 ) {
activate = ev->GetBoolean( 1 );
} else {
activate = qtrue;
}
if( n && activate )
{
UIWidgetContainer *widcon = ( UIWidgetContainer * )m_itemlist.ObjectAt( 1 );
uWinMan.ActivateControl( widcon );
widcon->SetLastActiveWidgetOrderNum();
}
uWinMan.setFirstResponder( NULL );
}
void Menu::HideMenu
(
Event *ev
)
{
int i, n;
bool force = false;
float maxtime;
maxtime = GetMaxMotionTime();
if( ev->NumArgs() > 0 )
force = ev->GetBoolean( 1 );
n = m_itemlist.NumObjects();
for( i = 1; i <= n; i++ )
{
UIWidget *wid = m_itemlist.ObjectAt( i );
if( wid->getMotionType() != MOTION_OUT )
{
wid->ResetMotion( MOTION_OUT );
if( !force )
{
Event *event = new Event( "hide" );
PostEvent( event, maxtime );
}
}
else
{
wid->setShow( false );
}
}
}
void Menu::ForceShow
(
void
)
{
int i;
int n;
n = m_itemlist.NumObjects();
for( i = 1; i <= n; i++ )
{
UIWidget *wid = m_itemlist.ObjectAt( i );
UIWidgetContainer *widcon = ( UIWidgetContainer * )wid;
if( wid->isSubclassOf( UIWidgetContainer ) && widcon->m_layout )
{
widcon->m_layout->ForceLoad();
}
if( wid->isEnabled() )
{
wid->setShow( true );
}
}
}
void Menu::ForceHide
(
void
)
{
int i;
int n;
n = m_itemlist.NumObjects();
for( i = 1; i <= n; i++ )
{
UIWidget *wid = m_itemlist.ObjectAt( i );
wid->ExecuteHideCommands();
wid->setShow( false );
}
}
UIWidget *Menu::GetContainerWidget
(
void
)
{
if( m_itemlist.NumObjects() > 0 ) {
return m_itemlist.ObjectAt( 1 );
} else {
return NULL;
}
}
UIWidget *Menu::GetNamedWidget
(
const char *pszName
)
{
int i;
UIWidget *pWidget;
for( i = 1; i <= m_itemlist.NumObjects(); i++ )
{
pWidget = m_itemlist.ObjectAt( i );
if( !stricmp( pszName, pWidget->getName() ) )
{
return pWidget;
}
}
return pWidget;
}
void Menu::Update
(
void
)
{
int i;
int n;
n = m_itemlist.NumObjects();
for( i = 1; i <= n; i++ )
{
UIWidget *wid = m_itemlist.ObjectAt( i );
wid->UpdateUIElement();
wid->UpdateData();
}
}
void Menu::RealignWidgets
(
void
)
{
int i;
int n;
n = m_itemlist.NumObjects();
for( i = 1; i <= n; i++ )
{
UIWidget *wid = m_itemlist.ObjectAt( i );
wid->Realign();
}
}
float Menu::GetMaxMotionTime
(
void
)
{
int i;
int n;
float maxtime = 0.0;
n = m_itemlist.NumObjects();
for( i = 1; i <= n; i++ )
{
UIWidget *wid = m_itemlist.ObjectAt( i );
if( maxtime < wid->getMotionTime() )
maxtime = wid->getMotionTime();
}
return maxtime;
}
void Menu::ActivateMenu
(
void
)
{
if( m_itemlist.NumObjects() )
{
UIWidgetContainer *widcon = ( UIWidgetContainer * )m_itemlist.ObjectAt( 1 );
uWinMan.ActivateControl( widcon );
widcon->SetLastActiveWidgetOrderNum();
uWinMan.setFirstResponder( NULL );
widcon->BringToFrontPropogated();
}
}
qboolean Menu::isFullscreen
(
void
)
{
return m_fullscreen;
}
void Menu::setFullscreen
(
qboolean bFullScreen
)
{
m_fullscreen = bFullScreen;
}
int Menu::getVidMode
(
void
)
{
return m_vidmode;
}
void Menu::setVidMode
(
int iMode
)
{
m_vidmode = iMode;
}
qboolean Menu::isVisible
(
void
)
{
UIWidget *wid = GetContainerWidget();
if( wid )
return wid->IsVisible();
return false;
}
void Menu::SaveCVars
(
void
)
{
int i;
int n;
n = m_itemlist.NumObjects();
for( i = 1; i <= n; i++ )
{
UIWidget *wid = m_itemlist.ObjectAt( i );
if( wid->m_cvarname.length() )
{
const char *ret = UI_GetCvarString( wid->m_cvarname, NULL );
if( ret )
wid->m_cvarvalue = ret;
else
wid->m_cvarvalue = "";
}
}
}
void Menu::RestoreCVars
(
void
)
{
int i;
int n;
n = m_itemlist.NumObjects();
for( i = 1; i <= n; i++ )
{
UIWidget *wid = m_itemlist.ObjectAt( i );
if( wid->m_cvarname.length() )
{
uii.Cvar_Set( wid->m_cvarvalue, "" );
}
}
}
void Menu::ResetCVars
(
void
)
{
int i;
int n;
n = m_itemlist.NumObjects();
for( i = 1; i <= n; i++ )
{
UIWidget *wid = m_itemlist.ObjectAt( i );
if( wid->m_cvarname.length() )
{
uii.Cvar_Reset( wid->m_cvarname );
}
}
}
void Menu::PassEventToWidget
(
str name,
Event *ev
)
{
int i;
int n;
n = m_itemlist.NumObjects();
for( i = 1; i <= n; i++ )
{
UIWidget *wid = m_itemlist.ObjectAt( i );
if( wid->getName() == name && wid->ValidEvent( ev->getName() ) )
{
wid->ProcessEvent( ev );
}
}
}
void Menu::PassEventToAllWidgets
(
Event& ev
)
{
int i;
int n;
n = m_itemlist.NumObjects();
for( i = 1; i <= n; i++ )
{
UIWidget *wid = m_itemlist.ObjectAt( i );
if( wid->ValidEvent( ev.getName() ) )
{
wid->ProcessEvent( ev );
}
}
}
void Menu::CheckRestart
(
void
)
{
cvar_t *cvar;
qboolean do_restart = false;
qboolean do_snd_restart = false;
qboolean do_ter_restart = false;
int i;
int n;
n = m_itemlist.NumObjects();
for( i = 1; i <= n; i++ )
{
UIWidget *wid = m_itemlist.ObjectAt( i );
if( wid->m_cvarname.length() )
{
cvar = uii.Cvar_Find( wid->m_cvarname );
if( cvar && cvar->latchedString )
{
if( str::icmp( wid->m_cvarvalue, cvar->latchedString ) )
{
if( cvar->flags & CVAR_LATCH )
{
do_restart = true;
}
else if( cvar->flags & CVAR_SOUND_LATCH )
{
do_snd_restart = true;
}
else if( cvar->flags & CVAR_TERRAIN_LATCH )
{
do_ter_restart = true;
}
}
}
}
}
if( do_restart )
{
uii.Cmd_Stuff( "vid_restart\n" );
}
else
{
if( do_snd_restart ) {
uii.Cmd_Stuff( "snd_restart\n" );
}
if( do_ter_restart ) {
uii.Cmd_Stuff( "ter_restart\n" );
}
}
}
CLASS_DECLARATION( Listener, MenuManager, NULL )
{
{ NULL, NULL }
};
MenuManager::MenuManager()
{
// FIXME: stub
}
void MenuManager::RealignMenus
(
void
)
{
// FIXME: stub
}
void MenuManager::AddMenu
(
Menu *m
)
{
m_menulist.AddObject( m );
}
void MenuManager::DeleteMenu
(
Menu *m
)
{
m_menulist.RemoveObject( m );
}
void MenuManager::DeleteAllMenus
(
void
)
{
for( int i = m_menulist.NumObjects(); i > 0; i-- )
{
Menu *menu = m_menulist.ObjectAt( i );
delete menu;
}
}
Menu *MenuManager::FindMenu
(
str name
)
{
int i;
int count;
count = m_menulist.NumObjects();
for( i = 1; i <= count; i++ )
{
Menu *m = m_menulist.ObjectAt( i );
if( !str::icmp( m->m_name, name ) )
return m;
}
return NULL;
}
bool MenuManager::PushMenu
(
str name
)
{
Menu *m;
float maxouttime = 0.0;
float maxintime;
Menu *head;
if( m_lock )
{
return false;
}
m = FindMenu( name );
if( !m )
{
uii.Sys_Printf( "Couldn't find menu %s\n", name.c_str() );
return false;
}
// don't push the same menu
head = m_menustack.Head();
if( head == m )
{
return false;
}
m->SaveCVars();
if( head )
{
maxouttime = m->GetMaxMotionTime();
head->ProcessEvent( Event( "hidemenu" ) );
}
if( maxouttime == 0.0 )
{
m->ProcessEvent( Event( "showmenu" ) );
}
else
{
m->PostEvent( Event( "showmenu" ), maxouttime );
}
maxintime = m->GetMaxMotionTime();
Lock( NULL );
PostEvent( EV_UnlockMenus, maxintime + maxouttime );
m_menustack.Push( m );
return true;
}
bool MenuManager::ShowMenu
(
str name
)
{
Menu *m;
float maxintime;
if( m_lock )
{
return false;
}
m = FindMenu( name );
if( !m )
{
uii.Sys_Printf( "Couldn't find menu %s\n", name.c_str() );
return false;
}
m->SaveCVars();
m->ProcessEvent( new Event( "showmenu" ) );
maxintime = m->GetMaxMotionTime();
Lock( NULL );
PostEvent( EV_UnlockMenus, maxintime );
m_showmenustack.Push( m );
return true;
}
void MenuManager::PushMenu
(
Event *ev
)
{
if( !ui_pLoadingMenu || CurrentMenu() != ui_pLoadingMenu )
{
PushMenu( ev->GetString( 1 ) );
}
}
void MenuManager::PopMenu
(
qboolean restore_cvars
)
{
Menu *top;
Menu *head;
float maxtime;
if( m_lock )
{
return;
}
top = m_showmenustack.Pop();
if( top )
{
if( restore_cvars ) {
top->RestoreCVars();
}
//maxtime = top->GetMaxMotionTime();
top->ProcessEvent( Event( "hidemenu" ) );
}
else
{
top = m_menustack.Pop();
if( top )
{
if( restore_cvars ) {
top->RestoreCVars();
}
maxtime = top->GetMaxMotionTime();
top->ProcessEvent( Event( "hidemenu" ) );
head = m_menustack.Head();
if( head )
{
head->PostEvent( Event( "showmenu" ), maxtime );
}
Lock( NULL );
PostEvent( EV_UnlockMenus, maxtime );
}
}
}
Menu *MenuManager::CurrentMenu
(
void
)
{
Menu *head;
head = m_showmenustack.Head();
if( head )
{
return head;
}
head = m_menustack.Head();
if( head )
{
return head;
}
return NULL;
}
bool MenuManager::ClearMenus
(
bool force
)
{
// FIXME: stub
return false;
}
void MenuManager::ListMenus
(
void
)
{
int i;
int num;
num = m_menulist.NumObjects();
for( i = 1; i <= num; i++ )
{
Menu *menu = m_menulist.ObjectAt( i );
uii.Sys_Printf( "%s\n", menu->m_name.c_str() );
}
}
void MenuManager::UpdateAllMenus
(
void
)
{
int i;
int num;
num = m_menulist.NumObjects();
for( i = 1; i <= num; i++ )
{
Menu *menu = m_menulist.ObjectAt( i );
menu->Update();
}
}
void MenuManager::Lock
(
Event *ev
)
{
m_lock = true;
}
void MenuManager::Unlock
(
Event *ev
)
{
m_lock = false;
}
void MenuManager::PassEventToWidget
(
str name,
Event *ev
)
{
Menu *head = CurrentMenu();
if( head )
{
head->PassEventToWidget( name, ev );
}
}
void MenuManager::PassEventToAllWidgets
(
Event& ev
)
{
int i;
int iMenuCount;
iMenuCount = m_menulist.NumObjects();
for( i = 1; i <= iMenuCount; i++ )
{
Menu *pMenu = m_menulist.ObjectAt( i );
pMenu->PassEventToAllWidgets( ev );
}
}
void MenuManager::ResetCVars
(
void
)
{
Menu *head = CurrentMenu();
if( head )
{
head->ResetCVars();
}
}
void MenuManager::CheckRestart
(
void
)
{
Menu *head = CurrentMenu();
if( head )
{
head->CheckRestart();
}
}
bool MenuManager::ForceMenu
(
str name
)
{
Menu *m;
Menu *head;
m = FindMenu( name );
if( !m )
{
uii.Sys_Printf( "Couldn't find menu %s\n", name.c_str() );
return false;
}
// don't push the same menu
head = m_menustack.Head();
if( head == m )
{
return false;
}
m->SaveCVars();
if( head )
{
head->ForceHide();
}
m->ProcessEvent( Event( "showmenu" ) );
return true;
}

110
code/uilib/uimenu.h Normal file
View file

@ -0,0 +1,110 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIMENU_H__
#define __UIMENU_H__
class Menu : public Listener {
qboolean m_fullscreen;
int m_vidmode;
public:
CLASS_PROTOTYPE( Menu );
public:
Container<UIWidget *> m_itemlist;
str m_name;
public:
Menu();
Menu( str name );
void AddMenuItem( UIWidget *item );
void DeleteMenuItem( UIWidget *item );
void setName( str name );
void ShowMenu( Event *ev );
void HideMenu( Event *ev );
void ForceShow( void );
void ForceHide( void );
UIWidget *GetContainerWidget( void );
UIWidget *GetNamedWidget( const char *pszName );
void Update( void );
void RealignWidgets( void );
float GetMaxMotionTime( void );
void ActivateMenu( void );
qboolean isFullscreen( void );
void setFullscreen( qboolean bFullScreen );
int getVidMode( void );
void setVidMode( int iMode );
qboolean isVisible( void );
void SaveCVars( void );
void RestoreCVars( void );
void ResetCVars( void );
void PassEventToWidget( str name, Event *ev );
void PassEventToAllWidgets( Event& ev );
void CheckRestart( void );
};
class MenuManager : public Listener {
Container<Menu *> m_menulist;
Stack<Menu *> m_showmenustack;
Stack<Menu *> m_menustack;
bool m_lock;
public:
CLASS_PROTOTYPE( MenuManager );
public:
MenuManager();
void RealignMenus( void );
void AddMenu( Menu *m );
void DeleteMenu( Menu *m );
void DeleteAllMenus( void );
Menu *FindMenu( str name );
bool PushMenu( str name );
bool ShowMenu( str name );
void PushMenu( Event *ev );
void PopMenu( qboolean restore_cvars );
Menu *CurrentMenu( void );
bool ClearMenus( bool force );
void ListMenus( void );
void UpdateAllMenus( void );
void Lock( Event *ev );
void Unlock( Event *ev );
void PassEventToWidget( str name, Event *ev );
void PassEventToAllWidgets( Event& ev );
void ResetCVars( void );
void CheckRestart( void );
bool ForceMenu( str name );
};
extern MenuManager menuManager;
extern Event EV_PushMenu;
extern Event EV_LockMenus;
extern Event EV_UnlockMenus;
extern Event EV_ShowMenu;
extern Event EV_HideMenu;
#endif

288
code/uilib/uimledit.cpp Normal file
View file

@ -0,0 +1,288 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UIMultiLineEdit, NULL )
{
{ NULL, NULL }
};
UIMultiLineEdit::UIMultiLineEdit()
{
// FIXME: stub
}
void UIMultiLineEdit::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UIMultiLineEdit::PointToSelectionPoint
(
UIPoint2D& p,
selectionpoint_t& sel
)
{
// FIXME: stub
}
static str str_null = "";
str& UIMultiLineEdit::LineFromLineNumber
(
int num,
bool resetpos
)
{
// FIXME: stub
return str_null;
}
void UIMultiLineEdit::EnsureSelectionPointVisible
(
selectionpoint_t& point
)
{
// FIXME: stub
}
void UIMultiLineEdit::BoundSelectionPoint
(
selectionpoint_t& point
)
{
// FIXME: stub
}
void UIMultiLineEdit::SortSelection
(
selectionpoint_t **topsel,
selectionpoint_t **botsel
)
{
// FIXME: stub
}
void UIMultiLineEdit::UpdateCvarEvent
(
Event *ev
)
{
// FIXME: stub
}
void UIMultiLineEdit::SetEdit
(
Event *ev
)
{
// FIXME: stub
}
bool UIMultiLineEdit::IsSelectionEmpty
(
void
)
{
// FIXME: stub
return false;
}
void UIMultiLineEdit::Draw
(
void
)
{
// FIXME: stub
}
qboolean UIMultiLineEdit::KeyEvent
(
int key,
unsigned int time
)
{
// FIXME: stub
return qfalse;
}
void UIMultiLineEdit::CharEvent
(
int ch
)
{
// FIXME: stub
}
UIPoint2D UIMultiLineEdit::getEndSelPoint
(
void
)
{
// FIXME: stub
return UIPoint2D();
}
void UIMultiLineEdit::MouseDown
(
Event *ev
)
{
// FIXME: stub
}
void UIMultiLineEdit::MouseUp
(
Event *ev
)
{
// FIXME: stub
}
void UIMultiLineEdit::MouseDragged
(
Event *ev
)
{
// FIXME: stub
}
void UIMultiLineEdit::Scroll
(
Event *ev
)
{
// FIXME: stub
}
void UIMultiLineEdit::DragTimer
(
Event *ev
)
{
// FIXME: stub
}
void UIMultiLineEdit::SizeChanged
(
Event *ev
)
{
// FIXME: stub
}
void UIMultiLineEdit::setData
(
const char *data
)
{
// FIXME: stub
}
void UIMultiLineEdit::getData
(
str& data
)
{
// FIXME: stub
}
void UIMultiLineEdit::Empty
(
void
)
{
// FIXME: stub
}
void UIMultiLineEdit::CopySelection
(
void
)
{
// FIXME: stub
}
void UIMultiLineEdit::PasteSelection
(
void
)
{
// FIXME: stub
}
void UIMultiLineEdit::DeleteSelection
(
void
)
{
// FIXME: stub
}
void UIMultiLineEdit::setChanged
(
bool b
)
{
// FIXME: stub
}
bool UIMultiLineEdit::IsChanged
(
void
)
{
// FIXME: stub
return false;
}

90
code/uilib/uimledit.h Normal file
View file

@ -0,0 +1,90 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIMLEDIT_H__
#define __UIMLEDIT_H__
typedef struct selectionpoint_s {
int line;
int column;
} selectionpoint_t;
typedef struct selection_s {
selectionpoint_s begin;
selectionpoint_s end;
} selection_t;
typedef struct dragState_s {
UIPoint2D lastPos;
} dragState_t;
class UIMultiLineEdit : public UIWidget {
protected:
selection_s m_selection;
dragState_s m_dragState;
UList<str> m_lines;
UIVertScroll *m_vertscroll;
mouseState_t m_mouseState;
bool m_shiftForcedDown;
bool m_edit;
bool m_changed;
public:
CLASS_PROTOTYPE( UIMultiLineEdit );
protected:
void FrameInitialized( void );
void PointToSelectionPoint( UIPoint2D& p, selectionpoint_t& sel );
str& LineFromLineNumber( int num, bool resetpos );
void EnsureSelectionPointVisible( selectionpoint_t& point );
void BoundSelectionPoint( selectionpoint_t& point );
void SortSelection( selectionpoint_t **topsel, selectionpoint_t **botsel );
void UpdateCvarEvent( Event *ev );
void SetEdit( Event *ev );
bool IsSelectionEmpty( void );
public:
UIMultiLineEdit();
void Draw( void );
qboolean KeyEvent( int key, unsigned int time );
void CharEvent( int ch );
UIPoint2D getEndSelPoint( void );
void MouseDown( Event *ev );
void MouseUp( Event *ev );
void MouseDragged( Event *ev );
void Scroll( Event *ev );
void DragTimer( Event *ev );
void SizeChanged( Event *ev );
void setData( const char *data );
void getData( str& data );
void Empty( void );
void CopySelection( void );
void PasteSelection( void );
void DeleteSelection( void );
void setChanged( bool b );
bool IsChanged( void );
};
#endif

266
code/uilib/uinotepad.cpp Normal file
View file

@ -0,0 +1,266 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIMultiLineEdit, UINotepadEdit, NULL )
{
{ NULL, NULL }
};
bool UI_LoadNotepadFile( const char *filename )
{
return false;
}
UINotepadEdit::UINotepadEdit()
{
// FIXME: stub
}
void UINotepadEdit::CharEvent
(
int ch
)
{
// FIXME: stub
}
void UINotepadEdit::setNotepad
(
UINotepad *notepad
)
{
// FIXME: stub
}
bool UINotepadEdit::GotoLine
(
int line
)
{
// FIXME: stub
return false;
}
bool UINotepadEdit::FindText
(
const char *text,
int offsetFromSel
)
{
// FIXME: stub
return false;
}
void UINotepadEdit::MousePressed
(
Event *ev
)
{
// FIXME: stub
}
CLASS_DECLARATION( UIFloatingWindow, UINotepad, NULL )
{
{ NULL, NULL }
};
UINotepad::UINotepad()
{
// FIXME: stub
}
void UINotepad::TimeMessage
(
const char *message,
int howlong
)
{
// FIXME: stub
}
bool UINotepad::OpenFile
(
const char *filename
)
{
// FIXME: stub
return false;
}
bool UINotepad::Create
(
UIWidget *parent,
UIRect2D& rect,
const char *filename
)
{
// FIXME: stub
return false;
}
void UINotepad::ChildSizeChanged
(
Event *ev
)
{
// FIXME: stub
}
void UINotepad::SaveAs
(
Event *ev
)
{
// FIXME: stub
}
void UINotepad::Save
(
Event *ev
)
{
// FIXME: stub
}
void UINotepad::Open
(
Event *ev
)
{
// FIXME: stub
}
void UINotepad::OpenFile
(
Event *ev
)
{
// FIXME: stub
}
void UINotepad::ClosePressed
(
Event *ev
)
{
// FIXME: stub
}
void UINotepad::OnFind
(
Event *ev
)
{
// FIXME: stub
}
void UINotepad::OnGoto
(
Event *ev
)
{
// FIXME: stub
}
void UINotepad::OnCopy
(
Event *ev
)
{
// FIXME: stub
}
void UINotepad::OnPaste
(
Event *ev
)
{
// FIXME: stub
}
void UINotepad::OnCut
(
Event *ev
)
{
// FIXME: stub
}
bool UINotepad::ProcessControlEvents
(
int ch
)
{
// FIXME: stub
return false;
}
bool UINotepad::ProcessCharEvent
(
int ch
)
{
// FIXME: stub
return false;
}
void UINotepad::Draw
(
void
)
{
// FIXME: stub
}
void UINotepad::setFileName
(
const char *filename
)
{
// FIXME: stub
}

106
code/uilib/uinotepad.h Normal file
View file

@ -0,0 +1,106 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UINOTEPAD_H__
#define __UINOTEPAD_H__
class UINotepad;
class UINotepadEdit : public UIMultiLineEdit {
protected:
UINotepad *m_notepad;
public:
CLASS_PROTOTYPE( UINotepadEdit );
public:
UINotepadEdit();
void CharEvent( int ch );
void setNotepad( UINotepad *notepad );
bool GotoLine( int line );
bool FindText( const char *text, int offsetFromSel );
void MousePressed( Event *ev );
};
typedef enum { STATE_NONE, STATE_GOTO_LINE, STATE_FIND_TEXT, STATE_SAVE_AS, STATE_TIMED_MESSAGE, STATE_CONFIRMCLOSE } state_t;
typedef struct textinput_s {
str text;
} textinput_t;
typedef struct timedmessage_s {
int die;
str text;
} timedmessage_t;
typedef struct ctrlevent_s {
char ch;
Event *ev;
} ctrlevent_t;
class UINotepad : public UIFloatingWindow {
private:
Container<Container<uipopup_describe *> *> m_popups;
protected:
state_t m_state;
textinput_s m_textinput;
timedmessage_s m_timedmessage;
str m_lastfind;
str m_filename;
UINotepadEdit *m_edit;
UIStatusBar *m_status;
class UIPulldownMenu *m_menu;
public:
CLASS_PROTOTYPE( UINotepad );
protected:
void TimeMessage( const char *message, int howlong );
public:
UINotepad();
bool OpenFile( const char *filename );
bool Create( UIWidget *parent, UIRect2D& rect, const char *filename );
void ChildSizeChanged( Event *ev );
void SaveAs( Event *ev );
void Save( Event *ev );
void Open( Event *ev );
void OpenFile( Event *ev );
void ClosePressed( Event *ev );
void OnFind( Event *ev );
void OnGoto( Event *ev );
void OnCopy( Event *ev );
void OnPaste( Event *ev );
void OnCut( Event *ev );
bool ProcessControlEvents( int ch );
bool ProcessCharEvent( int ch );
void Draw( void );
void setFileName( const char *filename );
};
bool UI_LoadNotepadFile( const char *filename );
#endif

68
code/uilib/uipoint2d.h Normal file
View file

@ -0,0 +1,68 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIPOINT2D_H__
#define __UIPOINT2D_H__
class UIPoint2D {
public:
float x;
float y;
UIPoint2D();
UIPoint2D( float x, float y );
bool operator==( const UIPoint2D& pos ) const;
bool operator!=( const UIPoint2D& pos ) const;
};
inline
UIPoint2D::UIPoint2D()
{
x = y = 0;
}
inline
UIPoint2D::UIPoint2D
(
float x,
float y
)
{
this->x = x;
this->y = y;
}
inline
bool UIPoint2D::operator==( const UIPoint2D& pos ) const
{
return ( x == pos.x && y == pos.y );
}
inline
bool UIPoint2D::operator!=( const UIPoint2D& pos ) const
{
return ( x != pos.x || y != pos.y );
}
#endif /* __UIPOINT2D_H__ */

265
code/uilib/uipopupmenu.cpp Normal file
View file

@ -0,0 +1,265 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UIPopupMenu, NULL )
{
{ NULL, NULL }
};
UIPopupMenu::UIPopupMenu()
{
// FIXME: stub
}
uipopup_describe *UIPopupMenu::getDescribeFromPoint
(
const UIPoint2D& p
)
{
// FIXME: stub
return NULL;
}
void UIPopupMenu::MakeSubMenu
(
void
)
{
// FIXME: stub
}
float UIPopupMenu::getDescribeHeight
(
uipopup_describe *d
)
{
// FIXME: stub
return 0.0f;
}
float UIPopupMenu::getDescribeWidth
(
uipopup_describe *d
)
{
// FIXME: stub
return 0.0f;
}
bool UIPopupMenu::MouseInSubmenus
(
void
)
{
// FIXME: stub
return false;
}
void UIPopupMenu::Create
(
Container<uipopup_describe*> *describe,
Listener *listener,
const UIPoint2D& where
)
{
// FIXME: stub
}
void UIPopupMenu::Create
(
Container<uipopup_describe*> *describe,
Listener *listener,
const UIRect2D& createRect,
uipopup_where where,
qboolean bVirtualSize,
float width
)
{
// FIXME: stub
}
void UIPopupMenu::YouAreASubmenu
(
UIPopupMenu *me
)
{
// FIXME: stub
}
void UIPopupMenu::Draw
(
void
)
{
// FIXME: stub
}
void UIPopupMenu::MouseReleased
(
Event *ev
)
{
// FIXME: stub
}
void UIPopupMenu::MouseMoved
(
Event *ev
)
{
// FIXME: stub
}
void UIPopupMenu::MouseExited
(
Event *ev
)
{
// FIXME: stub
}
void UIPopupMenu::Dismiss
(
void
)
{
// FIXME: stub
}
void UIPopupMenu::DismissEvent
(
Event *ev
)
{
// FIXME: stub
}
void UIPopupMenu::setAutoDismiss
(
bool b
)
{
// FIXME: stub
}
void UIPopupMenu::setNextSelection
(
void
)
{
// FIXME: stub
}
void UIPopupMenu::setPrevSelection
(
void
)
{
// FIXME: stub
}
uipopup_describe *UIPopupMenu::getSelectedDescribe
(
void
)
{
// FIXME: stub
return NULL;
}
void UIPopupMenu::setSelection
(
int sel
)
{
// FIXME: stub
}
void UIPopupMenu::setHighlightFGColor
(
UColor c
)
{
// FIXME: stub
}
void UIPopupMenu::setHighlightBGColor
(
UColor c
)
{
// FIXME: stub
}
void UIPopupMenu::setPopupHighlightBGColor
(
str menu,
UColor c
)
{
// FIXME: stub
}
void UIPopupMenu::setPopupHighlightFGColor
(
str menu,
UColor c
)
{
// FIXME: stub
}
void UIPopupMenu::getPulldown
(
str title
)
{
// FIXME: stub
}

113
code/uilib/uipopupmenu.h Normal file
View file

@ -0,0 +1,113 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIPOPUPMENU_H__
#define __UIPOPUPMENU_H__
typedef enum { UIP_NONE, UIP_EVENT, UIP_EVENT_STRING, UIP_SUBMENU, UIP_CMD, UIP_CVAR, UIP_SEPARATOR } uipopup_type;
typedef enum { UIP_WHERE_RIGHT, UIP_WHERE_DOWN } uipopup_where;
class uipopup_describe {
public:
str title;
UIReggedMaterial *material;
uipopup_type type;
void *data;
uipopup_describe();
uipopup_describe( str title, uipopup_type type, void *data, UIReggedMaterial *material );
};
inline
uipopup_describe::uipopup_describe()
{
title = "";
material = NULL;
type = UIP_NONE;
data = NULL;
}
inline
uipopup_describe::uipopup_describe
(
str title,
uipopup_type type,
void *data,
UIReggedMaterial *material
)
{
this->title = title;
this->type = type;
this->data = data;
this->material = material;
}
class UIPopupMenu : public UIWidget {
protected:
Container<uipopup_describe *> *m_describe;
int m_selected;
Listener *m_listener;
class UIPopupMenu *m_parentMenu;
class UIPopupMenu *m_submenuptr;
int m_submenu;
UIFont m_marlett;
bool m_autodismiss;
UColor m_highlightFGColor;
UColor m_highlightBGColor;
public:
CLASS_PROTOTYPE( UIPopupMenu );
protected:
uipopup_describe *getDescribeFromPoint( const UIPoint2D& p );
void MakeSubMenu( void );
virtual float getDescribeHeight( uipopup_describe *d );
virtual float getDescribeWidth( uipopup_describe *d );
bool MouseInSubmenus( void );
public:
UIPopupMenu();
void Create( Container<uipopup_describe*> *describe, Listener *listener, const UIPoint2D& where );
void Create( Container<uipopup_describe*> *describe, Listener *listener, const UIRect2D& createRect, uipopup_where where, qboolean bVirtualSize, float width );
void YouAreASubmenu( UIPopupMenu *me );
void Draw( void );
void MouseReleased( Event *ev );
void MouseMoved( Event *ev );
void MouseExited( Event *ev );
void Dismiss( void );
void DismissEvent( Event *ev );
void setAutoDismiss( bool b );
void setNextSelection( void );
void setPrevSelection( void );
uipopup_describe *getSelectedDescribe( void );
void setSelection( int sel );
void setHighlightFGColor( UColor c );
void setHighlightBGColor( UColor c );
void setPopupHighlightBGColor( str menu, UColor c );
void setPopupHighlightFGColor( str menu, UColor c );
void getPulldown( str title );
};
#endif

View file

@ -0,0 +1,255 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UIPulldownMenu, NULL )
{
{ NULL, NULL }
};
UIPulldownMenu::UIPulldownMenu()
{
// FIXME: stub
}
UIRect2D UIPulldownMenu::getAlignmentRect
(
UIWidget *parent
)
{
// FIXME: stub
return UIRect2D();
}
float UIPulldownMenu::getDescWidth
(
uipull_describe *desc
)
{
// FIXME: stub
return 0.0f;
}
float UIPulldownMenu::getDescHeight
(
uipull_describe *desc
)
{
// FIXME: stub
return 0.0f;
}
uipull_describe *UIPulldownMenu::getPulldown
(
str title
)
{
// FIXME: stub
return NULL;
}
void UIPulldownMenu::HighlightBGColor
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenu::HighlightFGColor
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenu::Create
(
UIWidget *parent,
Listener *listener,
const UIRect2D& rect
)
{
// FIXME: stub
}
void UIPulldownMenu::CreateAligned
(
UIWidget *parent,
Listener *listener
)
{
// FIXME: stub
}
void UIPulldownMenu::MousePressed
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenu::MouseDragged
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenu::MouseReleased
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenu::ChildKilled
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenu::AddUIPopupDescribe
(
const char *title,
uipopup_describe *d
)
{
// FIXME: stub
}
void UIPulldownMenu::setHighlightFGColor
(
UColor c
)
{
// FIXME: stub
}
void UIPulldownMenu::setHighlightBGColor
(
UColor c
)
{
// FIXME: stub
}
void UIPulldownMenu::setPopupHighlightFGColor
(
str menu,
UColor c
)
{
// FIXME: stub
}
void UIPulldownMenu::setPopupHighlightBGColor
(
str menu,
UColor c
)
{
// FIXME: stub
}
void UIPulldownMenu::setPopupFGColor
(
str menu,
UColor c
)
{
// FIXME: stub
}
void UIPulldownMenu::setPopupBGColor
(
str menu,
UColor c
)
{
// FIXME: stub
}
void UIPulldownMenu::setPulldownShader
(
const char *title,
UIReggedMaterial *mat
)
{
// FIXME: stub
}
void UIPulldownMenu::setSelectedPulldownShader
(
const char *title,
UIReggedMaterial *mat
)
{
// FIXME: stub
}
void UIPulldownMenu::Realign
(
void
)
{
// FIXME: stub
}
void UIPulldownMenu::Draw
(
void
)
{
// FIXME: stub
}

106
code/uilib/uipulldownmenu.h Normal file
View file

@ -0,0 +1,106 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIPULLDOWNMENU_H__
#define __UIPULLDOWNMENU_H__
class uipull_describe {
public:
str title;
UColor highlightFGColor;
UColor highlightBGColor;
UColor FGColor;
UColor BGColor;
UIReggedMaterial *material;
UIReggedMaterial *selected_material;
Container<uipopup_describe *> desc;
uipull_describe();
uipull_describe( str title, UIReggedMaterial *material, UIReggedMaterial *selected_material );
};
inline
uipull_describe::uipull_describe()
{
title = "";
material = NULL;
selected_material = NULL;
}
inline
uipull_describe::uipull_describe
(
str title,
UIReggedMaterial *material,
UIReggedMaterial *selected_material
)
{
this->title = title;
this->material = material;
this->selected_material = selected_material;
}
class UIPulldownMenu : public UIWidget {
protected:
Container<uipull_describe *> m_desc;
Listener *m_listener;
int m_submenu;
UIPopupMenu *m_submenuptr;
UColor m_highlightBGColor;
UColor m_highlightFGColor;
public:
CLASS_PROTOTYPE( UIPulldownMenu );
protected:
UIRect2D getAlignmentRect( UIWidget *parent );
float getDescWidth( uipull_describe *desc );
float getDescHeight( uipull_describe *desc );
uipull_describe *getPulldown( str title );
void HighlightBGColor( Event *ev );
void HighlightFGColor( Event *ev );
public:
UIPulldownMenu();
void Create( UIWidget *parent, Listener *listener, const UIRect2D& rect );
void CreateAligned( UIWidget *parent, Listener *listener );
void MousePressed( Event *ev );
void MouseDragged( Event *ev );
void MouseReleased( Event *ev );
void ChildKilled( Event *ev );
void AddUIPopupDescribe( const char *title, uipopup_describe *d );
void setHighlightFGColor( UColor c );
void setHighlightBGColor( UColor c );
void setPopupHighlightFGColor( str menu, UColor c );
void setPopupHighlightBGColor( str menu, UColor c );
void setPopupFGColor( str menu, UColor c );
void setPopupBGColor( str menu, UColor c );
void setPulldownShader( const char *title, UIReggedMaterial *mat );
void setSelectedPulldownShader( const char *title, UIReggedMaterial *mat );
void Realign( void );
void Draw( void );
};
#endif

View file

@ -0,0 +1,170 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UIPulldownMenuContainer, NULL )
{
{ NULL, NULL }
};
UIPulldownMenuContainer::UIPulldownMenuContainer()
{
// FIXME: stub
}
void UIPulldownMenuContainer::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UIPulldownMenuContainer::setBackgroundAlpha
(
float f
)
{
// FIXME: stub
}
void UIPulldownMenuContainer::setBackgroundColor
(
const UColor& color,
bool setbordercolor
)
{
// FIXME: stub
}
void UIPulldownMenuContainer::setForegroundColor
(
const UColor& color
)
{
// FIXME: stub
}
void UIPulldownMenuContainer::SetPopupHighlightFGColor
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenuContainer::SetPopupHighlightBGColor
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenuContainer::SetPopupFGColor
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenuContainer::SetPopupBGColor
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenuContainer::SetHighlightFGColor
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenuContainer::SetHighlightBGColor
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenuContainer::SetMenuShader
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenuContainer::SetSelectedMenuShader
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenuContainer::Realign
(
void
)
{
// FIXME: stub
}
void UIPulldownMenuContainer::PulldownVirtualRes
(
Event *ev
)
{
// FIXME: stub
}
void UIPulldownMenuContainer::AddPopup
(
Event *ev
)
{
// FIXME: stub
}

View file

@ -0,0 +1,58 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIPULLDOWNMENUCONTAINER_H__
#define __UIPULLDOWNMENUCONTAINER_H__
class UIPulldownMenuContainer : public UIWidget {
protected:
Container<uipopup_describe *> m_popups;
Container<char *> m_dataContainer;
UIPulldownMenu *m_menu;
public:
CLASS_PROTOTYPE( UIPulldownMenuContainer );
UIPulldownMenuContainer();
protected:
void FrameInitialized( void );
void setBackgroundAlpha( float f );
void setBackgroundColor( const UColor& color, bool setbordercolor );
void setForegroundColor( const UColor& color );
void SetPopupHighlightFGColor( Event *ev );
void SetPopupHighlightBGColor( Event *ev );
void SetPopupFGColor( Event *ev );
void SetPopupBGColor( Event *ev );
void SetHighlightFGColor( Event *ev );
void SetHighlightBGColor( Event *ev );
void SetMenuShader( Event *ev );
void SetSelectedMenuShader( Event *ev );
void Realign( void );
void PulldownVirtualRes( Event *ev );
public:
void AddPopup( Event *ev );
};
#endif

220
code/uilib/uirect2d.h Normal file
View file

@ -0,0 +1,220 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIRECT2D_H__
#define __UIRECT2D_H__
class UIRect2D {
public:
UIPoint2D pos;
UISize2D size;
public:
UIRect2D();
UIRect2D( float x, float y, float width, float height );
UIRect2D( const UIPoint2D& pos, const UISize2D& size );
float getMinX() const;
float getMinY() const;
float getMaxX() const;
float getMaxY() const;
UIPoint2D getUpperLeft() const;
UIPoint2D getUpperRight() const;
UIPoint2D getLowerLeft() const;
UIPoint2D getLowerRight() const;
bool contains( const UIPoint2D& pos ) const;
bool contains( float x, float y ) const;
bool contains( int x, int y ) const;
bool contains( const UIRect2D& pos ) const;
bool intersects( const UIRect2D& pos ) const;
};
inline
UIRect2D::UIRect2D()
{
}
inline
UIRect2D::UIRect2D
(
float x,
float y,
float width,
float height
)
{
pos = UIPoint2D( x, y );
size = UISize2D( width, height );
}
inline
UIRect2D::UIRect2D
(
const UIPoint2D& pos,
const UISize2D& size
)
{
this->pos = pos;
this->size = size;
}
inline
float UIRect2D::getMinX
(
void
) const
{
return pos.x;
}
inline
float UIRect2D::getMinY
(
void
) const
{
return pos.y;
}
inline
float UIRect2D::getMaxX
(
void
) const
{
return pos.x + size.width;
}
inline
float UIRect2D::getMaxY
(
void
) const
{
return pos.y + size.height;
}
inline
UIPoint2D UIRect2D::getUpperLeft
(
void
) const
{
return UIPoint2D( getMinX(), getMinY() );
}
inline
UIPoint2D UIRect2D::getUpperRight
(
void
) const
{
return UIPoint2D( getMaxX(), getMinY() );
}
inline
UIPoint2D UIRect2D::getLowerLeft
(
void
) const
{
return UIPoint2D( getMinX(), getMaxY() );
}
inline
UIPoint2D UIRect2D::getLowerRight
(
void
) const
{
return UIPoint2D( getMaxX(), getMaxY() );
}
inline
bool UIRect2D::contains
(
const UIPoint2D& pos
) const
{
return pos.x >= this->pos.x && pos.x <= this->pos.x + size.width
&& pos.y >= this->pos.y && pos.y <= this->pos.y + size.height;
}
inline
bool UIRect2D::contains
(
float x,
float y
) const
{
return x >= this->pos.x && x <= this->pos.x + size.width
&& y >= this->pos.y && y <= this->pos.y + size.height;
}
inline
bool UIRect2D::contains
(
int x,
int y
) const
{
return x >= this->pos.x && x <= this->pos.x + size.width
&& y >= this->pos.y && y <= this->pos.y + size.height;
}
inline
bool UIRect2D::contains
(
const UIRect2D& pos
) const
{
return pos.pos.x >= this->pos.x && pos.pos.x <= this->pos.x + size.width
&& pos.pos.y >= this->pos.y && pos.pos.y <= this->pos.y + size.height;
}
inline
bool UIRect2D::intersects
(
const UIRect2D& pos
) const
{
// FIXME: stub
return false;
}
#endif // __UIRECT2D_H__

69
code/uilib/uisize2d.h Normal file
View file

@ -0,0 +1,69 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UISIZE2D_H__
#define __UISIZE2D_H__
class UISize2D {
public:
float width;
float height;
public:
UISize2D();
UISize2D( float width, float height );
bool operator==( const UISize2D& pos ) const;
bool operator!=( const UISize2D& pos ) const;
};
inline
UISize2D::UISize2D()
{
width = height = 0.0f;
}
inline
UISize2D::UISize2D
(
float width,
float height
)
{
this->width = width;
this->height = height;
}
inline
bool UISize2D::operator==( const UISize2D& pos ) const
{
return ( width == pos.width && height == pos.height );
}
inline
bool UISize2D::operator!=( const UISize2D& pos ) const
{
return ( width != pos.width || height != pos.height );
}
#endif /* __UISIZE2D_H__ */

262
code/uilib/uislider.cpp Normal file
View file

@ -0,0 +1,262 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UISlider, NULL )
{
{ NULL, NULL }
};
UISlider::UISlider()
{
// FIXME: stub
}
void UISlider::setThumb
(
void
)
{
// FIXME: stub
}
void UISlider::Pressed
(
Event *ev
)
{
// FIXME: stub
}
void UISlider::Released
(
Event *ev
)
{
// FIXME: stub
}
void UISlider::Increment
(
void
)
{
// FIXME: stub
}
void UISlider::Decrement
(
void
)
{
// FIXME: stub
}
void UISlider::AutoIncrement
(
Event *ev
)
{
// FIXME: stub
}
void UISlider::AutoDecrement
(
Event *ev
)
{
// FIXME: stub
}
void UISlider::MouseExited
(
Event *ev
)
{
// FIXME: stub
}
void UISlider::MouseDragged
(
Event *ev
)
{
// FIXME: stub
}
void UISlider::MouseEntered
(
Event *ev
)
{
// FIXME: stub
}
void UISlider::UpdateData
(
void
)
{
// FIXME: stub
}
void UISlider::UpdateUIElement
(
void
)
{
// FIXME: stub
}
void UISlider::LayoutSetRange
(
Event *ev
)
{
// FIXME: stub
}
void UISlider::LayoutSetType
(
Event *ev
)
{
// FIXME: stub
}
void UISlider::LayoutSetStep
(
Event *ev
)
{
// FIXME: stub
}
void UISlider::LayoutSliderBGShader
(
Event *ev
)
{
// FIXME: stub
}
void UISlider::LayoutSliderThumbShader
(
Event *ev
)
{
// FIXME: stub
}
void UISlider::LayoutSliderLeftShader
(
Event *ev
)
{
// FIXME: stub
}
void UISlider::LayoutSliderRightShader
(
Event *ev
)
{
// FIXME: stub
}
void UISlider::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UISlider::Draw
(
void
)
{
// FIXME: stub
}
void UISlider::setType
(
slidertype_t type
)
{
// FIXME: stub
}
qboolean UISlider::KeyEvent
(
int key,
unsigned int time
)
{
// FIXME: stub
return qfalse;
}
void UISlider::setRange
(
float min,
float max
)
{
// FIXME: stub
}
void UISlider::setStep
(
float value
)
{
// FIXME: stub
}

90
code/uilib/uislider.h Normal file
View file

@ -0,0 +1,90 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UISLIDER_H__
#define __UISLIDER_H__
typedef enum { SLIDER_FLOAT, SLIDER_INTEGER } slidertype_t;
class UISlider : public UIWidget {
bool m_initialized;
float m_minvalue;
float m_maxvalue;
int m_minx;
int m_maxx;
int m_arrow_width;
float m_value;
float m_oldvalue;
float m_sliderwidth;
UIRect2D m_sliderregion;
UIRect2D m_prev_arrow_region;
UIRect2D m_next_arrow_region;
slidertype_t m_slidertype;
float m_stepsize;
bool m_prev_arrow_depressed;
bool m_next_arrow_depressed;
bool m_thumb_depressed;
UIReggedMaterial *m_bar_material;
UIReggedMaterial *m_prev_arrow_material;
UIReggedMaterial *m_next_arrow_material;
UIReggedMaterial *m_thumbmaterial;
UIReggedMaterial *m_prev_arrow_material_pressed;
UIReggedMaterial *m_next_arrow_material_pressed;
UIReggedMaterial *m_thumbmaterial_pressed;
public:
CLASS_PROTOTYPE( UISlider );
private:
void setThumb( void );
void Pressed( Event *ev );
void Released( Event *ev );
void Increment( void );
void Decrement( void );
void AutoIncrement( Event *ev );
void AutoDecrement( Event *ev );
void MouseExited( Event *ev );
void MouseDragged( Event *ev );
void MouseEntered( Event *ev );
void UpdateData( void );
void UpdateUIElement();
void LayoutSetRange( Event *ev );
void LayoutSetType( Event *ev );
void LayoutSetStep( Event *ev );
void LayoutSliderBGShader( Event *ev );
void LayoutSliderThumbShader( Event *ev );
void LayoutSliderLeftShader( Event *ev );
void LayoutSliderRightShader( Event *ev );
public:
UISlider();
void FrameInitialized( void );
void Draw( void );
void setType( slidertype_t type );
qboolean KeyEvent( int key, unsigned int time );
void setRange( float min, float max );
void setStep( float value );
};
#endif

183
code/uilib/uistatus.cpp Normal file
View file

@ -0,0 +1,183 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UIWindowSizer, NULL )
{
{ NULL, NULL }
};
UIWindowSizer::UIWindowSizer()
{
// FIXME: stub
}
void UIWindowSizer::Draw
(
void
)
{
// FIXME: stub
}
void UIWindowSizer::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UIWindowSizer::MouseDown
(
Event *ev
)
{
// FIXME: stub
}
void UIWindowSizer::MouseUp
(
Event *ev
)
{
// FIXME: stub
}
void UIWindowSizer::MouseDragged
(
Event *ev
)
{
// FIXME: stub
}
void UIWindowSizer::setDraggingWidget
(
UIWidget *w
)
{
// FIXME: stub
}
UIWidget *UIWindowSizer::getDraggingWidget
(
void
)
{
// FIXME: stub
return NULL;
}
CLASS_DECLARATION( UIWidget, UIStatusBar, NULL )
{
{ NULL, NULL }
};
UIStatusBar::UIStatusBar()
{
// FIXME: stub
}
UIStatusBar::UIStatusBar
(
alignment_t align,
float height
)
{
// FIXME: stub
}
void UIStatusBar::FrameInitialized
(
void
)
{
// FIXME: stub
}
void UIStatusBar::Draw
(
void
)
{
// FIXME: stub
}
void UIStatusBar::AlignBar
(
alignment_t align,
float height
)
{
// FIXME: stub
}
void UIStatusBar::DontAlignBar
(
void
)
{
// FIXME: stub
}
void UIStatusBar::EnableSizeBox
(
UIWidget *which
)
{
// FIXME: stub
}
void UIStatusBar::ParentSized
(
Event *ev
)
{
// FIXME: stub
}
void UIStatusBar::SelfSized
(
Event *ev
)
{
// FIXME: stub
}

82
code/uilib/uistatus.h Normal file
View file

@ -0,0 +1,82 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UISTATUS_H__
#define __UISTATUS_H__
typedef enum { M_NONE, M_DRAGGING } mouseState_t;
class UIWindowSizer : public UIWidget {
protected:
class UIWidget *m_draggingwidget;
mouseState_t m_mouseState;
UIPoint2D m_screenDragPoint;
public:
CLASS_PROTOTYPE( UIWindowSizer );
UIWindowSizer();
void Draw( void );
void FrameInitialized( void );
void MouseDown( Event *ev );
void MouseUp( Event *ev );
void MouseDragged( Event *ev );
void setDraggingWidget( UIWidget *w );
UIWidget *getDraggingWidget( void );
};
typedef enum { WND_ALIGN_NONE, WND_ALIGN_BOTTOM } alignment_t;
typedef struct align_s {
public:
float dist;
alignment_t alignment;
} align_t;
class UIStatusBar : public UIWidget {
protected:
align_t m_align;
class UIWidget *m_sizeenabled;
bool m_created;
UIWindowSizer *m_sizer;
public:
CLASS_PROTOTYPE( UIStatusBar );
protected:
void FrameInitialized( void );
public:
UIStatusBar();
UIStatusBar( alignment_t align, float height );
void Draw( void );
void AlignBar( alignment_t align, float height );
void DontAlignBar( void );
void EnableSizeBox( UIWidget *which );
void ParentSized( Event *ev );
void SelfSized( Event *ev );
};
#endif

232
code/uilib/uivertscroll.cpp Normal file
View file

@ -0,0 +1,232 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "ui_local.h"
CLASS_DECLARATION( UIWidget, UIVertScroll, NULL )
{
{ NULL, NULL }
};
UIVertScroll::UIVertScroll()
{
// FIXME: stub
}
int UIVertScroll::getItemFromHeight
(
float height
)
{
// FIXME: stub
return 0;
}
bool UIVertScroll::isEnoughItems
(
void
)
{
// FIXME: stub
return false;
}
void UIVertScroll::Draw
(
void
)
{
// FIXME: stub
}
void UIVertScroll::DrawArrow
(
float top,
const char *text,
bool pressed
)
{
// FIXME: stub
}
void UIVertScroll::DrawThumb
(
void
)
{
// FIXME: stub
}
void UIVertScroll::MouseDown
(
Event *ev
)
{
// FIXME: stub
}
void UIVertScroll::MouseUp
(
Event *ev
)
{
// FIXME: stub
}
void UIVertScroll::MouseDragged
(
Event *ev
)
{
// FIXME: stub
}
void UIVertScroll::MouseEnter
(
Event *ev
)
{
// FIXME: stub
}
void UIVertScroll::MouseLeave
(
Event *ev
)
{
// FIXME: stub
}
void UIVertScroll::Scroll
(
Event *ev
)
{
// FIXME: stub
}
bool UIVertScroll::AttemptScrollTo
(
int to
)
{
// FIXME: stub
return false;
}
void UIVertScroll::setNumItems
(
int i
)
{
// FIXME: stub
}
void UIVertScroll::setPageHeight
(
int i
)
{
// FIXME: stub
}
void UIVertScroll::setTopItem
(
int i
)
{
// FIXME: stub
}
int UIVertScroll::getTopItem
(
void
)
{
// FIXME: stub
return 0;
}
int UIVertScroll::getPageHeight
(
void
)
{
// FIXME: stub
return 0;
}
int UIVertScroll::getNumItems
(
void
)
{
// FIXME: stub
return 0;
}
void UIVertScroll::setThumbColor
(
const UColor& thumb
)
{
// FIXME: stub
}
void UIVertScroll::setSolidBorderColor
(
const UColor& col
)
{
// FIXME: stub
}
void UIVertScroll::InitFrameAlignRight
(
UIWidget *parent,
float fWidthPadding,
float fHeightPadding
)
{
// FIXME: stub
}

77
code/uilib/uivertscroll.h Normal file
View file

@ -0,0 +1,77 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIVERTSCROLL_H__
#define __UIVERTSCROLL_H__
class unnamed_struct {
public:
int itemOffset;
int orgItem;
};
class UIVertScroll : public UIWidget {
protected:
int m_numitems;
int m_pageheight;
int m_topitem;
UIFont m_marlett;
whatspressed m_pressed;
UIRect2D thumbRect;
unnamed_struct m_dragThumbState;
bool m_frameinitted;
UColor m_thumbcolor;
UColor m_solidbordercolor;
public:
CLASS_PROTOTYPE( UIVertScroll );
protected:
int getItemFromHeight( float height );
bool isEnoughItems( void );
public:
UIVertScroll();
void Draw( void );
void DrawArrow( float top, const char *text, bool pressed );
void DrawThumb( void );
void MouseDown( Event *ev );
void MouseUp( Event *ev );
void MouseDragged( Event *ev );
void MouseEnter( Event *ev );
void MouseLeave( Event *ev );
void Scroll( Event *ev );
bool AttemptScrollTo( int to );
void setNumItems( int i );
void setPageHeight( int i );
void setTopItem( int i );
int getTopItem( void );
int getPageHeight( void );
int getNumItems( void );
void setThumbColor( const UColor& thumb );
void setSolidBorderColor( const UColor& col );
void InitFrameAlignRight( UIWidget *parent, float fWidthPadding, float fHeightPadding );
};
#endif

3236
code/uilib/uiwidget.cpp Normal file

File diff suppressed because it is too large Load diff

370
code/uilib/uiwidget.h Normal file
View file

@ -0,0 +1,370 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UI_WIDGET_H__
#define __UI_WIDGET_H__
typedef struct item_s {
} item_t;
class UIReggedMaterial {
uihandle_t hMat;
str name;
bool isSet;
bool isGot;
public:
UIReggedMaterial();
uihandle_t GetMaterial( void );
void ReregisterMaterial( void );
void CleanupMaterial( void );
void SetMaterial( const str& name );
void RefreshMaterial( void );
str GetName( void );
};
// widget flags
#define WF_STRETCH_VERTICAL (1<<0)
#define WF_STRETCH_HORIZONTAL (1<<1)
#define WF_DIRECTED (1<<2)
#define WF_TILESHADER (1<<3)
#define WF_ALWAYS_BOTTOM (1<<4)
#define WF_ALWAYS_TOP (1<<5)
#define WF_NOPARENTADJUST (1<<6)
// widget alignment flags
#define WA_LEFT (1<<0)
#define WA_RIGHT (1<<1)
#define WA_TOP (1<<3)
#define WA_BOTTOM (1<<4)
#define WA_CENTERX (1<<5)
#define WA_CENTERY (1<<6)
#define WA_FULL ( WA_LEFT | WA_RIGHT | WA_TOP | WA_BOTTOM | WA_CENTERX | WA_CENTERY )
typedef class UIReggedMaterial UIReggedMaterial;
typedef enum { border_none, border_3D, border_indent, border_outline } borderstyle_t;
typedef enum { D_NONE, D_FROM_LEFT, D_FROM_RIGHT, D_FROM_BOTTOM, D_FROM_TOP } direction_t;
typedef enum { MOTION_IN, MOTION_OUT } motion_t;
class UIWidget : public USignal {
friend class Menu;
friend class UILayout;
friend class UIWindowManager;
protected:
UIRect2D m_frame;
vec2_t m_vVirtualScale;
UIPoint2D m_startingpos;
UIPoint2D m_origin;
UIRect2D m_screenframe;
UIPoint2D m_screenorigin;
UIRect2D m_clippedframe;
UIPoint2D m_clippedorigin;
UColor m_background_color;
UColor m_foreground_color;
UBorderColor m_border_color;
borderstyle_t m_borderStyle;
bool m_visible;
bool m_enabled;
UIFont *m_font;
class UIWidget *m_parent;
Container<UIWidget *> m_children;
str m_name;
bool m_canactivate;
str m_cvarname;
str m_cvarvalue;
str m_command;
Container<str *> m_showcommands;
Container<str *> m_hidecommands;
str m_title;
float m_indent;
float m_bottomindent;
UIReggedMaterial *m_material;
UIReggedMaterial *m_hovermaterial;
UIReggedMaterial *m_pressedmaterial;
bool m_hovermaterial_active;
bool m_pressedmaterial_active;
direction_t m_direction;
direction_t m_direction_orig;
motion_t m_motiontype;
float m_starttime;
float m_fadetime;
float m_alpha;
float m_local_alpha;
float m_motiontime;
str m_stopsound;
str m_clicksound;
int m_align;
int m_flags;
bool m_dying;
int m_ordernum;
int m_configstring_index;
fonthorzjustify_t m_iFontAlignmentHorizontal;
fontvertjustify_t m_iFontAlignmentVertical;
qboolean m_bVirtual;
str m_enabledCvar;
public:
CLASS_PROTOTYPE( UIWidget );
void( *m_commandhandler ) ( const char *, void * );
protected:
bool addChild( UIWidget *widget );
bool removeChild( UIWidget *widget );
void PropogateCoordinateSystem( void );
void set2D( void );
virtual void Draw( void );
virtual void FrameInitialized( void );
void DrawTitle( float x, float y );
void Motion( void );
virtual void AlignPosition( void );
void Hide( Event *ev );
void Activate( Event *ev );
void BringToFront( void );
static void SplitWidgets( Container<UIWidget*>& src, Container<UIWidget*>& bottom, Container<UIWidget*>& normal, Container<UIWidget*>& top );
static void CombineWidgets( Container<UIWidget*>& dst, Container<UIWidget*>& bottom, Container<UIWidget*>& normal, Container<UIWidget*>& top );
static void ArrangeWidgetList( Container<UIWidget*>& list );
public:
UIWidget();
virtual ~UIWidget();
virtual void Shutdown( void );
virtual void InitFrame( UIWidget *parentview, float x, float y, float width, float height, int border = -1, const char *fontname = "verdana-12" );
void InitFrame( UIWidget *parentview, const UIRect2D& r, int border, const char *fontname );
void LayoutSize( Event *ev );
void LayoutRect( Event *ev );
void LayoutName( Event *ev );
void LayoutTitle( Event *ev );
void LayoutFont( Event *ev );
void LayoutBgColor( Event *ev );
void LayoutFgColor( Event *ev );
void LayoutBorderStyle( Event *ev );
void LayoutBorderColor( Event *ev );
void LayoutShader( Event *ev );
void LayoutTileShader( Event *ev );
void LayoutHoverShader( Event *ev );
void LayoutPressedShader( Event *ev );
void LayoutFadeIn( Event *ev );
void LayoutStopSound( Event *ev );
void LayoutClickSound( Event *ev );
void LayoutStretch( Event *ev );
void LayoutVirtualRes( Event *ev );
void LayoutInitData( Event *ev );
void LayoutDirection( Event *ev );
void LayoutAlign( Event *ev );
void LayoutStuffCommand( Event *ev );
void LayoutLinkCvar( Event *ev );
void LayoutNoParentClipping( Event *ev );
void LayoutNoParentAdjustment( Event *ev );
void LayoutOrderNumber( Event *ev );
void TextAlignment( Event *ev );
void LayoutAliasCache( Event *ev );
void SetEnabledCvar( Event *ev );
void setParent( UIWidget *parent );
class UIWidget *getParent( void );
class UIWidget *getFirstChild( void );
class UIWidget *getNextSibling( void );
class UIWidget *getNextChild( UIWidget *child );
class UIWidget *getPrevChild( UIWidget *child );
class UIWidget *getPrevSibling( void );
class UIWidget *getPrevSibling( UIWidget *curr );
class UIWidget *getLastSibling( void );
class UIWidget *findSibling( str name );
void Enable( void );
void Disable( void );
bool isEnabled( void );
bool IsDying( void );
class UIWidget *FindResponder( const UIPoint2D& pos );
void setFont( const char *name );
void setFontHorizontalAlignment( fonthorzjustify_t alignment );
void setFontVerticalAlignment( fontvertjustify_t alignment );
void setShow( bool visible );
bool getShow( void );
class UColor getBackgroundColor( void );
virtual void setBackgroundColor( const UColor& color, bool setbordercolor );
class UBorderColor getBorderColor( void );
void setBorderColor( const UBorderColor& color );
class UColor getForegroundColor( void );
virtual void setForegroundColor( const UColor& color );
borderstyle_t getBorderStyle( void );
void setBorderStyle( borderstyle_t style );
class UISize2D getSize( void );
void setSize( const UISize2D& newsize );
class UIRect2D getFrame( void );
void setFrame( const UIRect2D& newframe );
class UIPoint2D getOrigin( void );
void setOrigin( const UIPoint2D& neworigin );
void setName( str name );
const char *getName( void );
void setTitle( str title );
const char *getTitle( void );
void setDirection( direction_t dir );
direction_t getDirection( void );
void setMotionType( motion_t type );
motion_t getMotionType( void );
void setMotionTime( float time );
float getMotionTime( void );
void setAlign( int align );
int getAlign( void );
void setMaterial( UIReggedMaterial *mat );
void setHoverMaterial( UIReggedMaterial *mat );
void setPressedMaterial( UIReggedMaterial *mat );
class UIPoint2D getLocalPoint( const UIPoint2D& pos );
class UIPoint2D getGlobalPoint( const UIPoint2D& pos );
virtual void setBackgroundAlpha( float f );
float getBackgroundAlpha( void );
void Display( const UIRect2D& drawframe, float parent_alpha );
virtual qboolean KeyEvent( int key, unsigned int time );
virtual void CharEvent( int ch );
virtual void UpdateData( void );
virtual void UpdateUIElement( void );
float getTitleWidth( void );
float getTitleHeight( void );
bool CanActivate( void );
void AllowActivate( bool canactivate );
bool IsActive( void );
bool IsVisible( void );
virtual void LinkCvar( str cvarname );
void LinkCommand( str cmd );
void ExecuteShowCommands( void );
void ExecuteHideCommands( void );
void InitializeCommandHandler( void( *fcn) ( const char *, void * ) );
class UIWidget *FindWidget( str name );
void ResetMotion( motion_t type );
virtual void Realign( void );
void BringToFrontPropogated( void );
class UIWidget *IsThisOrChildActive( void );
class UIPoint2D MouseEventToClientPoint( Event *ev );
class UIRect2D getClientFrame( void );
void setAlwaysOnBottom( bool b );
void setAlwaysOnTop( bool b );
bool getAlwaysOnBottom( void );
bool getAlwaysOnTop( void );
bool SendSignal( Event& event );
void ShowCommand( Event *ev );
void HideCommand( Event *ev );
void AddFlag( int flag );
void SetHovermaterialActive( bool a );
void SetPressedmaterialActive( bool a );
int getOrderNum( void );
class str getCommand( void );
void ActivateOrder( void );
void EnableEvent( Event *ev );
void DisableEvent( Event *ev );
void setConfigstringIndex( int cs );
int getConfigstringIndex( void );
bool PassEventToWidget( str name, Event *ev );
};
class UIWidgetContainer : public UIWidget {
UColor m_bgfill;
qboolean m_fullscreen;
int m_vidmode;
int m_currentwidnum;
int m_maxordernum;
public:
class UILayout *m_layout;
CLASS_PROTOTYPE( UIWidgetContainer );
private:
void AlignPosition( void );
void Draw( void );
public:
UIWidgetContainer();
void Realign( void );
void SetBGFill( Event *ev );
void SetFullscreen( Event *ev );
void SetVidMode( Event *ev );
int getVidMode( void );
qboolean isFullscreen( void );
UIWidget *GetNextWidgetInOrder( void );
UIWidget *GetPrevWidgetInOrder( void );
void SetActiveWidgetOrderNum( UIWidget *wid );
void SetActiveWidgetOrderNum( int num );
void SetLastActiveWidgetOrderNum( void );
};
extern Event W_Destroyed;
extern Event W_SizeChanged;
extern Event W_FrameChanged;
extern Event W_OriginChanged;
extern Event W_Activated;
extern Event EV_Widget_Activate;
extern Event W_Deactivated;
extern Event EV_Widget_Hide;
extern Event EV_Widget_Enable;
extern Event EV_Widget_Disable;
extern Event W_RealignWidget;
extern Event W_Draw;
extern Event EV_Layout_Size;
extern Event EV_Layout_Rect;
extern Event EV_Layout_Name;
extern Event EV_Layout_Title;
extern Event EV_Layout_Font;
extern Event EV_Layout_BGColor;
extern Event EV_Layout_FGColor;
extern Event EV_Layout_Borderstyle;
extern Event EV_Layout_BorderColor;
extern Event EV_Layout_Shader;
extern Event EV_Layout_TileShader;
extern Event EV_Layout_HoverShader;
extern Event EV_Layout_PressedShader;
extern Event EV_Layout_FadeIn;
extern Event EV_Layout_StopSound;
extern Event EV_Layout_ClickSound;
extern Event EV_Layout_Stretch;
extern Event EV_Layout_VirtualRes;
extern Event EV_Layout_InitData;
extern Event EV_Layout_Direction;
extern Event EV_Layout_Align;
extern Event EV_Layout_StuffCommand;
extern Event EV_Layout_LinkCvar;
extern Event EV_Layout_NoParentClipping;
extern Event EV_Layout_NoParentAdjustment;
extern Event EV_Widget_HideCommand;
extern Event EV_Widget_ShowCommand;
extern Event EV_Widget_OrderNumber;
extern Event EV_Widget_TextAlignment;
extern Event EV_Widget_EnabledCvar;
extern Event EV_Layout_AliasCache;
extern Event EV_Layout_BGFill;
extern Event EV_Layout_Fullscreen;
extern Event EV_Layout_VidMode;
void SetColor( const UColor& color, float alpha );
void DrawBox( const UIRect2D& rect, const UColor& color, float alpha );
void Draw3DBox( const UIRect2D& rect, bool indent, const UBorderColor& color, float alpha );
void DrawBox( float x, float y, float width, float height, const UColor &color, float alpha );
void Draw3DBox( float x, float y, float width, float height, bool indent, const UBorderColor& color, float alpha );
void DrawMac3DBox( const UIRect2D& rect, bool indent, const UBorderColor& color, int inset, float alpha );
void DrawBoxWithSolidBorder( const UIRect2D& rect, const UColor& inside, const UColor& outside, int size, int flags, float alpha );
#endif /* __UI_WIDGET_H__ */

1222
code/uilib/uiwinman.cpp Normal file

File diff suppressed because it is too large Load diff

109
code/uilib/uiwinman.h Normal file
View file

@ -0,0 +1,109 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UIWINMAN_H__
#define __UIWINMAN_H__
class Binding {
public:
str binding;
int key1;
int key2;
};
class UIWindowManager : public UIWidget {
unsigned int m_lastbuttons;
UIPoint2D m_oldpos;
SafePtr<UIWidget> m_oldview;
SafePtr<UIWidget> m_firstResponder;
class UIWidget *m_activeControl;
class UIWidget *m_backgroundwidget;
class UIReggedMaterial *m_cursor;
str m_cursorname;
bool m_showcursor;
Container<UIReggedMaterial *> m_materiallist;
bool m_amidead;
class UIWidget *m_bindactive;
Container<Binding *> bindings;
public:
CLASS_PROTOTYPE( UIWindowManager );
private:
void ViewEvent( UIWidget *view, Event& event, UIPoint2D& pos, int buttons );
UIWidget *getResponder( UIPoint2D& pos );
public:
UIWindowManager();
~UIWindowManager();
void Init( const UIRect2D& frame, const char *fontname );
void setBackgroundWidget( UIWidget *widget );
void UpdateViews( void );
void ServiceEvents( void );
void setFirstResponder( UIWidget *responder );
UIWidget *getFirstResponder( void );
UIWidget *ActiveControl( void );
void ActivateControl( UIWidget *control );
void DeactivateCurrentControl( void );
UIWidget *FindNextControl( UIWidget *control );
UIWidget *FindPrevControl( UIWidget *control );
void setCursor( const char *string );
void showCursor( bool show );
virtual void CharEvent( int ch );
virtual qboolean KeyEvent( int key, unsigned int time );
void CreateMenus( void );
UIReggedMaterial *RegisterShader( const str& name );
UIReggedMaterial *RefreshShader( const str& name );
void CleanupShadersFromList( void );
void RefreshShadersFromList( void );
void DeactivateCurrentSmart( void );
bool IsDead( void );
int AddBinding( str binding );
str GetKeyStringForCommand( str command, int index, qboolean alternate, int *key1, int *key2 );
void BindKeyToCommand( str command, int key, int index, qboolean alternate );
UIWidget *BindActive( void );
void SetBindActive( UIWidget *w );
virtual void Shutdown( void );
void DeactiveFloatingWindows( void );
bool DialogExists( void );
void RemoveAllDialogBoxes( void );
};
extern Event W_MouseExited;
extern Event W_MouseEntered;
extern Event W_LeftMouseDragged;
extern Event W_RightMouseDragged;
extern Event W_CenterMouseDragged;
extern Event W_MouseMoved;
extern Event W_LeftMouseDown;
extern Event W_LeftMouseUp;
extern Event W_RightMouseDown;
extern Event W_RightMouseUp;
extern Event W_CenterMouseDown;
extern Event W_CenterMouseUp;
extern Event W_AnyMouseDown;
extern Event W_AnyMouseUp;
extern UIWindowManager uWinMan;
#endif

355
code/uilib/ulist.h Normal file
View file

@ -0,0 +1,355 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __ULIST_H__
#define __ULIST_H__
template< typename type >
class UListItem {
public:
type item;
class UListItem< type > *next;
class UListItem< type > *prev;
UListItem();
};
template< typename type >
class UList {
UListItem<type> m_top;
UListItem<type> *m_at;
int m_count;
public:
UList();
~UList();
void AddHead( type& head );
void AddTail( const type& tail );
bool IterateFromHead( void );
bool IterateFromTail( void );
bool IterateNext( void );
bool IteratePrev( void );
type& getCurrent( void );
void RemoveCurrentSetNext( void );
void RemoveCurrentSetPrev( void );
bool IsCurrentValid( void );
bool IsCurrentHead( void );
bool IsCurrentTail( void );
void InsertBeforeCurrent( type& which );
void InsertAfterCurrent( type& which );
int getCount( void );
void RemoveAllItems( void );
void *getPosition( void );
void setPosition( void *pos );
};
template< typename type >
UListItem< type >::UListItem()
{
next = prev = NULL;
}
template< typename type >
UList< type >::UList()
{
m_at = NULL;
m_count = 0;
m_top.next = &m_top;
m_top.prev = &m_top;
}
template< typename type >
UList< type >::~UList()
{
RemoveAllItems();
}
template< typename type >
void UList< type >::AddHead
(
type& head
)
{
// FIXME: stub
}
template< typename type >
void UList< type >::AddTail
(
const type& tail
)
{
UListItem<type> *item = new UListItem <type>;
item->item = tail;
item->next = &m_top;
item->prev = m_top.prev;
m_top.prev = item;
m_top.prev->next = item;
m_count++;
}
template< typename type >
bool UList< type >::IterateFromHead
(
void
)
{
if( m_top.next == this )
{
m_at = NULL;
return false;
}
else
{
m_at = m_top.next;
return true;
}
}
template< typename type >
bool UList< type >::IterateFromTail
(
void
)
{
if( m_top.prev == this )
{
m_at = NULL;
return false;
}
else
{
m_at = m_top.prev;
return true;
}
}
template< typename type >
bool UList< type >::IterateNext
(
void
)
{
m_at = m_at->next;
if( m_at == this )
{
m_at = NULL;
return false;
}
else
{
return true;
}
}
template< typename type >
bool UList< type >::IteratePrev
(
void
)
{
m_at = m_at->prev;
if( m_at == this )
{
m_at = NULL;
return false;
}
else
{
return true;
}
}
template< typename type >
type& UList< type >::getCurrent
(
void
)
{
return m_at;
}
template< typename type >
void UList< type >::RemoveCurrentSetNext
(
void
)
{
UListItem<type> *item;
item = m_at;
IterateNext();
item->next->prev = item->prev;
item->prev->next = item->next;
delete item;
m_count--;
}
template< typename type >
void UList< type >::RemoveCurrentSetPrev
(
void
)
{
UListItem<type> *item;
item = m_at;
IteratePrev();
item->next->prev = item->prev;
item->prev->next = item->next;
delete item;
m_count--;
}
template< typename type >
bool UList< type >::IsCurrentValid
(
void
)
{
// FIXME: stub
}
template< typename type >
bool UList< type >::IsCurrentHead
(
void
)
{
// FIXME: stub
return false;
}
template< typename type >
bool UList< type >::IsCurrentTail
(
void
)
{
// FIXME: stub
return false;
}
template< typename type >
void UList< type >::InsertBeforeCurrent
(
type& which
)
{
// FIXME: stub
}
template< typename type >
void UList< type >::InsertAfterCurrent
(
type& which
)
{
UListItem<type> *item = new UListItem <type>;
item->item = which;
item->next = m_at->next;
item->prev = m_at;
m_at->next->prev = item;
item->prev->next = item;
m_count++;
}
template< typename type >
int UList< type >::getCount
(
void
)
{
// FIXME: stub
return 0;
}
template< typename type >
void UList< type >::RemoveAllItems
(
void
)
{
UListItem<type> *item;
UListItem<type> *next;
for( item = m_top.next; item && item != &m_top; item = next )
{
next = item->next;
delete item;
}
m_top.next = &m_top;
m_top.prev = &m_top;
m_count = 0;
}
template< typename type >
void *UList< type >::getPosition
(
void
)
{
// FIXME: stub
}
template< typename type >
void UList< type >::setPosition
(
void *pos
)
{
// FIXME: stub
}
#endif /* __ULIST_H__ */

51
code/uilib/usignal.h Normal file
View file

@ -0,0 +1,51 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __USIGNAL_H__
#define __USIGNAL_H__
class UConnection {
class Event m_inevent;
class Event m_outevent;
Container<SafePtr<Listener> > m_listeners;
Container<Event *> m_events;
public:
bool TypeIs( Event& ev );
bool AddListener( Listener *object, Event& ev );
bool RemoveListener( Listener *object );
bool SendEvent( Listener *object, Event& ev );
};
class USignal : public Listener {
Container<UConnection *> m_connections;
public:
CLASS_PROTOTYPE( USignal );
bool SendSignal( Event& ev );
bool Connect( Listener *object, Event& inevent, Event& outevent );
bool Disconnect( Listener *object, Event& ev );
bool Disconnect( Listener *object );
};
#endif /* __USIGNAL_H__ */