| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program 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 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /***********************************************************************************************
- *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
- ***********************************************************************************************
- * *
- * Project Name : Combat *
- * *
- * $Archive:: /Commando/Code/Combat/textwindow.h $*
- * *
- * Author:: Patrick Smith *
- * *
- * $Modtime:: 8/28/01 7:00p $*
- * *
- * $Revision:: 7 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #if defined(_MSC_VER)
- #pragma once
- #endif
- #ifndef __TEXT_WINDOW_H
- #define __TEXT_WINDOW_H
- #include "wwstring.h"
- #include "widestring.h"
- #include "vector.h"
- #include "vector3.h"
- #include "bittype.h"
- #include "rect.h"
- #include "render2d.h"
- ////////////////////////////////////////////////////////////////
- // Forward declarations
- ////////////////////////////////////////////////////////////////
- class Render2DSentenceClass;
- class RenderObjClass;
- class TextColumnClass;
- class SceneClass;
- ////////////////////////////////////////////////////////////////
- //
- // TextWindowClass
- //
- ////////////////////////////////////////////////////////////////
- class TextWindowClass
- {
- public:
-
- ////////////////////////////////////////////////////////////////
- // Public constructors/destructors
- ////////////////////////////////////////////////////////////////
- TextWindowClass (void);
- ~TextWindowClass (void);
- ////////////////////////////////////////////////////////////////
- // Public methods
- ////////////////////////////////////////////////////////////////
- //
- // Initialization
- //
- static void Initialize (SceneClass *scene);
- static void Shutdown (void);
- //
- // Backdrop methods
- //
- void Set_Backdrop (const char *texture_name, const RectClass &screen_rect, const Vector2 &texture_size, const RectClass &endcap_rect, const RectClass &fadeout_rect, const RectClass &textback_rect);
- void Set_Text_Area (const RectClass &rect) { TextRect = rect; }
-
- //
- // Font control
- //
- void Set_Heading_Font (const char *font_name) { HeadingFontName = font_name; }
- void Set_Text_Font (const char *font_name) { TextFontName = font_name; }
- //
- // Column support
- //
- void Add_Column (const WCHAR *column_name, float width, const Vector3 &color);
- bool Remove_Column (int index);
- void Delete_All_Columns (void);
- bool Are_Columns_Displayed (void) const { return AreColumnsDisplayed; }
- void Display_Columns (bool onoff) { AreColumnsDisplayed = onoff; IsViewDirty = true; IsWindowDirty = true; }
- //
- // Content control
- //
- int Insert_Item (int index, const WCHAR *text);
- bool Set_Item_Text (int index, int col_index, const WCHAR *text);
- bool Set_Item_Color (int index, int col_index, const Vector3 &color);
- bool Set_Item_Data (int index, uint32 user_data);
- uint32 Get_Item_Data (int index);
- bool Delete_Item (int index);
- void Delete_All_Items (void);
- int Get_Item_Count (void) const;
- //
- // Scrolling support
- //
- void Scroll_To_Top (void);
- void Page_Down (void);
- void Page_Up (void);
- //
- // Visibility methods
- //
- bool Is_Displayed (void) const { return IsDisplayed; }
- void Display (bool onoff);
- int Get_Display_Count (void);
- float Get_Total_Display_Height (void);
-
- //
- // Rendering methods
- //
- void On_Frame_Update (void);
- void Render (void);
- private:
- ////////////////////////////////////////////////////////////////
- // Private methods
- ////////////////////////////////////////////////////////////////
- void Free_Backdrop (void);
- void Free_Contents (void);
- void Free_Renderers (void);
- void Build_View (void);
- void Update_View (float *total_height = NULL, bool info_only = false);
- void Update_Row (int item_index, float y_pos, float *row_height);
- ////////////////////////////////////////////////////////////////
- // Private data types
- ////////////////////////////////////////////////////////////////
- typedef DynamicVectorClass<TextColumnClass *> COLUMN_LIST;
- ////////////////////////////////////////////////////////////////
- // Static member data
- ////////////////////////////////////////////////////////////////
- static SceneClass * Scene;
- ////////////////////////////////////////////////////////////////
- // Private member data
- ////////////////////////////////////////////////////////////////
- int FirstLineIndex;
- int CurrentDisplayCount;
- bool IsDisplayed;
- bool AreColumnsDisplayed;
- bool IsViewDirty;
- bool IsWindowDirty;
-
- COLUMN_LIST Columns;
- Render2DSentenceClass * TextRenderers[2];
- Render2DClass Backdrop;
- RectClass TextRect;
-
- float ColumnHeight;
- float LineSpacing;
- StringClass HeadingFontName;
- StringClass TextFontName;
- };
- ////////////////////////////////////////////////////////////////
- //
- // TextItemClass
- //
- ////////////////////////////////////////////////////////////////
- class TextItemClass
- {
- public:
-
- ////////////////////////////////////////////////////////////////
- // Public constructors/destructors
- ////////////////////////////////////////////////////////////////
- TextItemClass (void) :
- Name (L""),
- Color (1, 1, 1),
- UserData (0) {}
- TextItemClass (const WCHAR *name) :
- Name (name),
- Color (1, 1, 1),
- UserData (0) {}
- ~TextItemClass (void) {}
- ////////////////////////////////////////////////////////////////
- // Public methods
- ////////////////////////////////////////////////////////////////
-
- //
- // Name access
- //
- const WCHAR * Get_Name (void) const { return Name; }
- void Set_Name (const WCHAR *name) { Name = name; }
- //
- // Color access
- //
- const Vector3 & Get_Color (void) const { return Color; }
- void Set_Color (const Vector3 &color) { Color = color; }
- //
- // Color access
- //
- uint32 Get_User_Data (void) const { return UserData; }
- void Set_User_Data (uint32 user_data) { UserData = user_data; }
- private:
- ////////////////////////////////////////////////////////////////
- // Private member data
- ////////////////////////////////////////////////////////////////
- WideStringClass Name;
- Vector3 Color;
- uint32 UserData;
- };
- ////////////////////////////////////////////////////////////////
- //
- // TextColumnClass
- //
- ////////////////////////////////////////////////////////////////
- class TextColumnClass
- {
- public:
-
- ////////////////////////////////////////////////////////////////
- // Public constructors/destructors
- ////////////////////////////////////////////////////////////////
- TextColumnClass (void) :
- Width (0) { Reset_Contents (); }
- ~TextColumnClass (void) { Free_Data (); }
- ////////////////////////////////////////////////////////////////
- // Public methods
- ////////////////////////////////////////////////////////////////
-
- //
- // Name access
- //
- const WCHAR * Get_Name (void) const { return Header.Get_Name (); }
- void Set_Name (const WCHAR *name) { Header.Set_Name (name); }
- //
- // Width access
- //
- float Get_Width (void) const { return Width; }
- void Set_Width (float width) { Width = width; }
- //
- // Color access
- //
- const Vector3 & Get_Color (void) const { return Header.Get_Color (); }
- void Set_Color (const Vector3 &color) { Header.Set_Color (color); }
- //
- // Item access
- //
- int Insert_Item (int index, const WCHAR *item_name);
- int Get_Item_Count (void) const { return Items.Count (); }
- bool Delete_Item (int index);
- void Delete_All_Items (void);
-
- void Set_Item_Text (int index, const WCHAR *text) { Items[index]->Set_Name (text); }
- const WCHAR * Get_Item_Text (int index) const { return Items[index]->Get_Name (); }
-
- void Set_Item_Color (int index, const Vector3 &color) { Items[index]->Set_Color (color); }
- const Vector3 & Get_Item_Color (int index) const { return Items[index]->Get_Color (); }
- void Set_Item_Data (int index, uint32 data) { Items[index]->Set_User_Data (data); }
- uint32 Get_Item_Data (int index) const { return Items[index]->Get_User_Data (); }
- //
- // Cleanup
- //
- void Reset_Contents (void);
- private:
- ////////////////////////////////////////////////////////////////
- // Private methods
- ////////////////////////////////////////////////////////////////
- void Free_Data (void);
- ////////////////////////////////////////////////////////////////
- // Private data types
- ////////////////////////////////////////////////////////////////
- typedef DynamicVectorClass <TextItemClass *> ITEM_LIST;
- ////////////////////////////////////////////////////////////////
- // Private member data
- ////////////////////////////////////////////////////////////////
- TextItemClass Header;
- ITEM_LIST Items;
- float Width;
- };
- #endif //__TEXT_WINDOW_H
|