| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- /*
- ** 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/commando/dlgevaobjectivestab.cpp $*
- * *
- * Author:: Patrick Smith *
- * *
- * $Modtime:: 11/07/01 12:28p $*
- * *
- * $Revision:: 6 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "dlgevaobjectivestab.h"
- #include "listctrl.h"
- #include "string_ids.h"
- #include "translatedb.h"
- #include "objectives.h"
- #include "imagectrl.h"
- ////////////////////////////////////////////////////////////////
- // Local constants
- ////////////////////////////////////////////////////////////////
- enum
- {
- COL_PRIORITY = 0,
- COL_TEXT,
- COL_STATUS
- };
- //
- // This is extremely poor, but I need to get the index
- // of the currently displayed POG in the HUD.
- //
- extern int CurrentObjectiveIndex;
- ////////////////////////////////////////////////////////////////
- //
- // EvaObjectivesTabClass
- //
- ////////////////////////////////////////////////////////////////
- EvaObjectivesTabClass::EvaObjectivesTabClass (void) :
- ChildDialogClass (IDD_ENCYCLOPEDIA_OBJECTIVES_TAB)
- {
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Init_Dialog
- //
- ////////////////////////////////////////////////////////////////
- void
- EvaObjectivesTabClass::On_Init_Dialog (void)
- {
- //
- // Get a pointer to the list control
- //
- ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_OBJECTIVES_LIST_CTRL);
- if (list_ctrl != NULL) {
- //
- // Configure the list control
- //
- list_ctrl->Add_Column (TRANSLATE (IDS_OBJHDR_PRIORITY), 0.25F, Vector3 (1, 1, 1));
- list_ctrl->Add_Column (TRANSLATE (IDS_OBJHDR_OBJECTIVE), 0.5F, Vector3 (1, 1, 1));
- list_ctrl->Add_Column (TRANSLATE (IDS_OBJHDR_STATUS), 0.25F, Vector3 (1, 1, 1));
- Fill_Objectives_List ();
- }
- ChildDialogClass::On_Init_Dialog ();
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Command
- //
- ////////////////////////////////////////////////////////////////
- void
- EvaObjectivesTabClass::On_Command (int ctrl_id, int message_id, DWORD param)
- {
- ChildDialogClass::On_Command (ctrl_id, message_id, param);
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_ListCtrl_Sel_Change
- //
- ////////////////////////////////////////////////////////////////
- void
- EvaObjectivesTabClass::On_ListCtrl_Sel_Change (ListCtrlClass *list_ctrl, int ctrl_id, int old_index, int new_index)
- {
- if (ctrl_id == IDC_OBJECTIVES_LIST_CTRL) {
- Update_Curr_Objective_Controls ();
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Update_Curr_Objective_Controls
- //
- ////////////////////////////////////////////////////////////////
- void
- EvaObjectivesTabClass::Update_Curr_Objective_Controls (void)
- {
- //
- // Get a pointer to the list controls
- //
- ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_OBJECTIVES_LIST_CTRL);
- ImageCtrlClass *image_ctrl = (ImageCtrlClass *)Get_Dlg_Item (IDC_IMAGE);
- if (list_ctrl == NULL || image_ctrl == NULL) {
- return ;
- }
- //
- // Get the current selection from the list control
- //
- int curr_sel = list_ctrl->Get_Curr_Sel ();
- if (curr_sel >= 0) {
- Objective *objective = ObjectiveManager::Get_Objective (list_ctrl->Get_Entry_Data (curr_sel, 0));
- if (objective != NULL) {
-
- //
- // Put the long description into the edit control
- //
- Set_Dlg_Item_Text (IDC_DESCRIPTION_EDIT, TRANSLATE (objective->LongDescriptionID));
- //
- // Configure the image ctrl
- //
- image_ctrl->Set_Texture (objective->HUDPogTextureName);
- }
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Fill_Objectives_List
- //
- ////////////////////////////////////////////////////////////////
- void
- EvaObjectivesTabClass::Fill_Objectives_List (void)
- {
- //
- // Get a pointer to the list control
- //
- ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_OBJECTIVES_LIST_CTRL);
- if (list_ctrl == NULL) {
- return ;
- }
- //
- // Loop over all the objectives
- //
- int count = ObjectiveManager::Get_Objective_Count ();
- for (int index = 0; index < count; index ++) {
- Objective *objective = ObjectiveManager::Get_Objective (index);
- if (objective != NULL) {
-
- //
- // Don't display hidden objectives (unless you really want to)
- //
- if ( objective->Status != ObjectiveManager::STATUS_HIDDEN ||
- ObjectiveManager::Is_Objective_Debug_Mode_Enabled ())
- {
- //
- // Add this entry to the list
- //
- int item_index = list_ctrl->Insert_Entry (index, objective->Type_To_Name ());
- if (item_index != -1) {
- WideStringClass text = TRANSLATE (objective->ShortDescriptionID);
-
- //
- // Strip off the line delimiter (if necessary)
- //
- if (text.Get_Length () > 0 && text[text.Get_Length () - 1] == L'\n') {
- text.Erase (text.Get_Length () - 1, 1);
- }
- list_ctrl->Set_Entry_Text (item_index, COL_TEXT, text);
- list_ctrl->Set_Entry_Text (item_index, COL_STATUS, objective->Status_To_Name ());
- list_ctrl->Set_Entry_Data (item_index, 0, index);
- //
- // Colorize this entry
- //
- Vector3 color = objective->Type_To_Color ();
- list_ctrl->Set_Entry_Color (item_index, COL_PRIORITY, color);
- list_ctrl->Set_Entry_Color (item_index, COL_TEXT, color);
- list_ctrl->Set_Entry_Color (item_index, COL_STATUS, color);
- }
- }
- }
- }
- //
- // Sort the objectives...
- //
- list_ctrl->Sort (ListSortCallback, 0);
- //
- // Select the first entry by default
- //
- if (count > 0) {
- list_ctrl->Set_Curr_Sel (0);
- Update_Curr_Objective_Controls ();
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // ListSortCallback
- //
- ////////////////////////////////////////////////////////////////
- int CALLBACK
- EvaObjectivesTabClass::ListSortCallback
- (
- ListCtrlClass * list_ctrl,
- int item_index1,
- int item_index2,
- uint32 user_param
- )
- {
- int count = list_ctrl->Get_Entry_Count ();
- Objective *objective1 = ObjectiveManager::Get_Objective (list_ctrl->Get_Entry_Data (item_index1, 0));
- Objective *objective2 = ObjectiveManager::Get_Objective (list_ctrl->Get_Entry_Data (item_index2, 0));
- int result = 0;
- //
- // Sort the objective based on status
- //
- if ( objective1->Status != ObjectiveManager::STATUS_ACCOMPLISHED &&
- objective2->Status == ObjectiveManager::STATUS_ACCOMPLISHED)
- {
- result = -1;
- } else if ( objective1->Status == ObjectiveManager::STATUS_ACCOMPLISHED &&
- objective2->Status != ObjectiveManager::STATUS_ACCOMPLISHED)
- {
- result = 1;
- } else {
- if (item_index1 < CurrentObjectiveIndex) {
- item_index1 += count;
- }
- if (item_index2 < CurrentObjectiveIndex) {
- item_index2 += count;
- }
- //
- // Sort based on relative position to the current objective
- //
- result = (item_index1 - item_index2);
- }
-
- return result;
- }
|