0 Members and 1 Guest are viewing this topic.
//========= Copyright Valve Corporation, All rights reserved. ============////// Purpose: //// $NoKeywords: $//=============================================================================//#include "cbase.h"#ifdef _XBOX#include "xbox/xbox_platform.h"#include "xbox/xbox_win32stubs.h"#endif#pragma warning(push)#pragma warning(disable: 4005)#pragma warning(disable: 4668)#ifndef WIN32_LEAN_AND_MEAN#define WIN32_LEAN_AND_MEAN#endif#ifndef NOMINMAX#define NOMINMAX#endif#include <windows.h>#pragma warning(pop)#include <stdio.h>#include "filesystem.h"#include "gameversiondialog.h"#include "ModInfo.h"#include <vgui_controls/ListPanel.h>#include <KeyValues.h>// memdbgon must be the last include file in a .cpp file!!!#include <tier0/memdbgon.h>using namespace vgui;//-----------------------------------------------------------------------------// Purpose: Constructor//-----------------------------------------------------------------------------CChangeGameDialog::CChangeGameDialog(vgui::Panel* parent) : Frame(parent, "ChangeGameDialog"){ SetSize(400, 340); SetMinimumSize(400, 340); SetTitle("#GameUI_ChangeGame", true); m_pModList = new ListPanel(this, "ModList"); m_pModList->SetEmptyListText("#GameUI_NoOtherGamesAvailable"); m_pModList->AddColumnHeader(0, "ModName", "#GameUI_Game", 128); LoadModList(); LoadControlSettings("Resource/ChangeGameDialog.res"); // if there's a mod in the list, select the first one if (m_pModList->GetItemCount() > 0) { m_pModList->SetSingleSelectedItem(m_pModList->GetItemIDFromRow(0)); }}//-----------------------------------------------------------------------------// Purpose: Destructor//-----------------------------------------------------------------------------CChangeGameDialog::~CChangeGameDialog(){}//-----------------------------------------------------------------------------// Purpose: Fills the mod list//-----------------------------------------------------------------------------void CChangeGameDialog::LoadModList(){ char szSearchPath[_MAX_PATH + 5]; Q_strncpy(szSearchPath, "*.*", sizeof(szSearchPath)); WIN32_FIND_DATA wfd; HANDLE hResult = FindFirstFile(szSearchPath, &wfd); if (hResult == INVALID_HANDLE_VALUE) return; do { if ((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && Q_strnicmp(wfd.cFileName, ".", 1)) { // Build path to gameinfo.txt char szGameInfoPath[MAX_PATH + 16]; Q_snprintf(szGameInfoPath, sizeof(szGameInfoPath), "%s\\gameinfo.txt", wfd.cFileName); // Use engine file system FileHandle_t f = g_pFullFileSystem->Open(szGameInfoPath, "rb"); if (f) { // Get file size int size = g_pFullFileSystem->Size(f); if (size > 0) { char* buf = (char*)malloc(size + 1); if (g_pFullFileSystem->Read(buf, size, f) == size) { buf[size] = 0; CModInfo modInfo; modInfo.LoadGameInfoFromBuffer(buf); if (strcmp(modInfo.GetGameName(), ModInfo().GetGameName())) { strlwr(wfd.cFileName); KeyValues* itemData = new KeyValues("Mod"); itemData->SetString("ModName", modInfo.GetGameName()); itemData->SetString("ModDir", wfd.cFileName); m_pModList->AddItem(itemData, 0, false, false); } } free(buf); } g_pFullFileSystem->Close(f); } } } while (FindNextFile(hResult, &wfd)); FindClose(hResult);}//-----------------------------------------------------------------------------// Purpose: //-----------------------------------------------------------------------------void CChangeGameDialog::OnCommand(const char* command){ if (!stricmp(command, "OK")) { if (m_pModList->GetSelectedItemsCount() > 0) { KeyValues* kv = m_pModList->GetItem(m_pModList->GetSelectedItem(0)); if (kv) { // change the game dir and restart the engine char szCmd[256]; Q_snprintf(szCmd, sizeof(szCmd), "_setgamedir %s\n", kv->GetString("ModDir")); engine->ClientCmd_Unrestricted(szCmd); // Force restart of entire engine engine->ClientCmd_Unrestricted("_restart\n"); } } } else if (!stricmp(command, "Cancel")) { Close(); } else { BaseClass::OnCommand(command); }}
Привет всем, я пытаюсь перенести систему выбора игры(эпохи) из беты уже 2 неделю, но без успешно. Всё время система берёт игры из source sdk 2013, а не из папки мода. Есть у кого-то идеи как исправить?Code: [Select]//========= Copyright Valve Corporation, All rights reserved. ============////// Purpose: //// $NoKeywords: $//=============================================================================//#include "cbase.h"#ifdef _XBOX#include "xbox/xbox_platform.h"#include "xbox/xbox_win32stubs.h"#endif#pragma warning(push)#pragma warning(disable: 4005)#pragma warning(disable: 4668)#ifndef WIN32_LEAN_AND_MEAN#define WIN32_LEAN_AND_MEAN#endif#ifndef NOMINMAX#define NOMINMAX#endif#include <windows.h>#pragma warning(pop)#include <stdio.h>#include "filesystem.h"#include "gameversiondialog.h"#include "ModInfo.h"#include <vgui_controls/ListPanel.h>#include <KeyValues.h>// memdbgon must be the last include file in a .cpp file!!!#include <tier0/memdbgon.h>using namespace vgui;//-----------------------------------------------------------------------------// Purpose: Constructor//-----------------------------------------------------------------------------CChangeGameDialog::CChangeGameDialog(vgui::Panel* parent) : Frame(parent, "ChangeGameDialog"){ SetSize(400, 340); SetMinimumSize(400, 340); SetTitle("#GameUI_ChangeGame", true); m_pModList = new ListPanel(this, "ModList"); m_pModList->SetEmptyListText("#GameUI_NoOtherGamesAvailable"); m_pModList->AddColumnHeader(0, "ModName", "#GameUI_Game", 128); LoadModList(); LoadControlSettings("Resource/ChangeGameDialog.res"); // if there's a mod in the list, select the first one if (m_pModList->GetItemCount() > 0) { m_pModList->SetSingleSelectedItem(m_pModList->GetItemIDFromRow(0)); }}//-----------------------------------------------------------------------------// Purpose: Destructor//-----------------------------------------------------------------------------CChangeGameDialog::~CChangeGameDialog(){}//-----------------------------------------------------------------------------// Purpose: Fills the mod list//-----------------------------------------------------------------------------void CChangeGameDialog::LoadModList(){ char szSearchPath[_MAX_PATH + 5]; Q_strncpy(szSearchPath, "*.*", sizeof(szSearchPath)); WIN32_FIND_DATA wfd; HANDLE hResult = FindFirstFile(szSearchPath, &wfd); if (hResult == INVALID_HANDLE_VALUE) return; do { if ((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && Q_strnicmp(wfd.cFileName, ".", 1)) { // Build path to gameinfo.txt char szGameInfoPath[MAX_PATH + 16]; Q_snprintf(szGameInfoPath, sizeof(szGameInfoPath), "%s\\gameinfo.txt", wfd.cFileName); // Use engine file system FileHandle_t f = g_pFullFileSystem->Open(szGameInfoPath, "rb"); if (f) { // Get file size int size = g_pFullFileSystem->Size(f); if (size > 0) { char* buf = (char*)malloc(size + 1); if (g_pFullFileSystem->Read(buf, size, f) == size) { buf[size] = 0; CModInfo modInfo; modInfo.LoadGameInfoFromBuffer(buf); if (strcmp(modInfo.GetGameName(), ModInfo().GetGameName())) { strlwr(wfd.cFileName); KeyValues* itemData = new KeyValues("Mod"); itemData->SetString("ModName", modInfo.GetGameName()); itemData->SetString("ModDir", wfd.cFileName); m_pModList->AddItem(itemData, 0, false, false); } } free(buf); } g_pFullFileSystem->Close(f); } } } while (FindNextFile(hResult, &wfd)); FindClose(hResult);}//-----------------------------------------------------------------------------// Purpose: //-----------------------------------------------------------------------------void CChangeGameDialog::OnCommand(const char* command){ if (!stricmp(command, "OK")) { if (m_pModList->GetSelectedItemsCount() > 0) { KeyValues* kv = m_pModList->GetItem(m_pModList->GetSelectedItem(0)); if (kv) { // change the game dir and restart the engine char szCmd[256]; Q_snprintf(szCmd, sizeof(szCmd), "_setgamedir %s\n", kv->GetString("ModDir")); engine->ClientCmd_Unrestricted(szCmd); // Force restart of entire engine engine->ClientCmd_Unrestricted("_restart\n"); } } } else if (!stricmp(command, "Cancel")) { Close(); } else { BaseClass::OnCommand(command); }}