1
0
mirror of https://github.com/ncblakely/GiantsTools synced 2024-11-01 13:15:38 +01:00

Compare commits

..

No commits in common. "3fc16e8b6b382a0529e42965a7c22c2a6fb88e26" and "1377f51276509de793f6d313bccfe23cde2255e8" have entirely different histories.

13 changed files with 35 additions and 209 deletions

View File

@ -16,6 +16,7 @@ namespace Giants.Launcher
public partial class LauncherForm : Form
{
// Constant settings
private const string GameName = "Giants: Citizen Kabuto";
private const string GamePath = "GiantsMain.exe";
private const string RegistryKey = @"HKEY_CURRENT_USER\Software\PlanetMoon\Giants";
private const string RegistryValue = "DestDir";
@ -37,7 +38,7 @@ namespace Giants.Launcher
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
// Set window title
this.SetTitle();
this.Text = GameName;
// Read newer file-based game settings
this.config = new Config();
@ -96,7 +97,7 @@ namespace Giants.Launcher
private void btnOptions_Click(object sender, EventArgs e)
{
OptionsForm form = new OptionsForm(Resources.AppName + " Options", this.gamePath);
OptionsForm form = new OptionsForm(GameName + " Options", this.gamePath);
form.StartPosition = FormStartPosition.CenterParent;
form.ShowDialog();
@ -115,7 +116,7 @@ namespace Giants.Launcher
if (this.gamePath == null || !File.Exists(this.gamePath))
{
string message = string.Format(Resources.AppNotFound, Resources.AppName);
string message = string.Format(Resources.AppNotFound, GameName);
MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
return;
@ -130,7 +131,7 @@ namespace Giants.Launcher
Version gameVersion = VersionHelper.GetGameVersion(this.gamePath);
if (gameVersion == null)
{
string message = string.Format(Resources.AppNotFound, Resources.AppName);
string message = string.Format(Resources.AppNotFound, GameName);
MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
@ -333,21 +334,6 @@ namespace Giants.Launcher
}
Process.Start(this.communityAppUri);
}
private void SetTitle()
{
string title = Resources.AppName;
#if DEBUG
title += " DEBUG";
#endif
#if BETA
title += " BETA";
#endif
this.Text = title;
}
}
}

View File

@ -60,15 +60,6 @@ namespace Giants.Launcher {
}
}
/// <summary>
/// Looks up a localized string similar to Giants: Citizen Kabuto.
/// </summary>
internal static string AppName {
get {
return ResourceManager.GetString("AppName", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Could not locate an installation of {0}. The launcher will now exit..
/// </summary>

View File

@ -205,7 +205,4 @@
<data name="ErrorNoConfigFile" xml:space="preserve">
<value>Settings file {0} was not found.</value>
</data>
<data name="AppName" xml:space="preserve">
<value>Giants: Citizen Kabuto</value>
</data>
</root>

View File

@ -1,165 +0,0 @@
#pragma once
#include <float.h>
#include <math.h>
#include <memory>
#include <string>
#include <string_view>
//////////////////////////////////////////////////////////////////////////////////////
// Basic game data types and macros
typedef unsigned int uint;
typedef unsigned char UBYTE;
typedef signed char SBYTE;
typedef unsigned short UWORD;
typedef int BOOL;
typedef unsigned long ULONG;
typedef unsigned long DWORD;
typedef std::int64_t int64;
typedef std::uint64_t uint64;
#ifdef UNICODE
typedef std::wstring tstring;
typedef std::wstring_view tstring_view;
#else
typedef std::string tstring;
typedef std::string_view tstring_view;
#endif
#define countof(array) (sizeof((array)) / sizeof((array)[0]))
#define FlagSet(b, f) ((b) |= (f))
#define FlagClear(b, f) ((b) &= ~(f))
#define FlagIsClear(b, f) (!FlagIsSet(b, f))
#define FlagFlip(b, f) ((b) ^= (f))
#define FlagIsSet(b, f) (((b) & (f)) != 0)
//////////////////////////////////////////////////////////////////////////////////////
// Vectors
struct P3D
{
float x;
float y;
float z;
inline const P3D& operator -= (const P3D& rhs)
{
x -= rhs.x;
y -= rhs.y;
z -= rhs.z;
return *this;
}
inline const P3D& operator += (const P3D& rhs)
{
x += rhs.x;
y += rhs.y;
z += rhs.z;
return *this;
}
inline P3D operator - (const P3D& rhs)
{
P3D result;
result.x = x - rhs.x;
result.y = y - rhs.y;
result.z = z - rhs.z;
return result;
}
inline P3D Cross(const P3D& v2)
{
P3D result;
result.x = y * v2.z - z * v2.y;
result.y = z * v2.x - x * v2.z;
result.z = x * v2.y - y * v2.x;
return result;
}
inline float Dot(const P3D& v2)
{
return x * v2.x + y * v2.y + z * v2.z;
}
inline float Length()
{
return (float)(sqrt(x * x + y * y + z * z));
}
inline P3D Scale(float scale)
{
x *= scale;
y *= scale;
z *= scale;
return *this;
}
inline P3D Normalize()
{
float length = Length();
P3D normalized = *this;
float factor;
if (length)
{
factor = 1 / length;
}
else
{
factor = 1.0f;
}
normalized.x *= factor;
normalized.y *= factor;
normalized.z *= factor;
return normalized;
}
bool IsNaN() const
{
return (_isnan(x) || _isnan(y) || _isnan(z));
}
bool Finite() const
{
return (_finite(x) && _finite(y) && _finite(z));
}
};
#pragma pack (push, 1)
// Optimized 3D vector for network packets.
struct NetP3D
{
short x, y, z;
};
#pragma pack (pop)
//////////////////////////////////////////////////////////////////////////////////////
struct RGBFloat
{
float r{};
float g{};
float b{};
};
struct VertRGB
{
unsigned char r;
unsigned char g;
unsigned char b;
};
struct UV
{
float u, v;
};

View File

@ -16,7 +16,7 @@ struct IGiantsApiClient : IComponent
{
virtual ~IGiantsApiClient() = default;
virtual void STDMETHODCALLTYPE DeleteServerInformationAsync(tstring_view gameName, int hostPort) = 0;
virtual void STDMETHODCALLTYPE DeleteServerInformationAsync() = 0;
virtual ServerInfoFuture STDMETHODCALLTYPE GetServerInformationAsync() = 0;
virtual void STDMETHODCALLTYPE PostServerInformationAsync(const njson& requestBody) = 0;
};

View File

@ -104,7 +104,6 @@
<EnablePREfast>true</EnablePREfast>
<LanguageStandard>stdcpplatest</LanguageStandard>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -159,7 +158,6 @@
<EnablePREfast>true</EnablePREfast>
<LanguageStandard>stdcpplatest</LanguageStandard>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -215,6 +213,7 @@
</ClCompile>
<ClCompile Include="ServerDialog.cpp" />
<ClCompile Include="ServerConsoleApp.cpp" />
<ClCompile Include="Utils.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="res\ServerConsole.rc2" />
@ -227,6 +226,7 @@
<ClInclude Include="ServerDialog.h" />
<ClInclude Include="ServerConsoleApp.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="Utils.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ServerConsole.rc" />

View File

@ -1,4 +1,5 @@
#include "pch.h"
#include <initguid.h>
#include "ServerConsoleApp.h"
#include "ServerDialog.h"
@ -31,19 +32,18 @@ BOOL ServerConsoleApp::ExitInstance()
return CWinApp::ExitInstance();
}
IGameServerConsole* ServerConsoleApp::InitializeDialog(HWND hWndParent, IComponentContainer* container)
IGameServerConsole* ServerConsoleApp::InitializeDialog(IComponentContainer* container)
{
// Create the server console window.
// As this is also a Component, Giants will clean up this object automatically once
// it is no longer needed (i.e, there is no need to call delete).
auto* dialog = new ServerDialog(container, CWnd::FromHandle(hWndParent));
auto* dialog = new ServerDialog(container);
m_pMainWnd = dialog;
return dialog;
}
__declspec(dllexport) void CreateServerConsole(
int apiVersion,
HWND hWnd,
IComponentContainer* container)
{
if (apiVersion > 1)
@ -52,5 +52,5 @@ __declspec(dllexport) void CreateServerConsole(
}
AFX_MANAGE_STATE(AfxGetStaticModuleState());
ConsoleApp.InitializeDialog(hWnd, container);
ConsoleApp.InitializeDialog(container);
}

View File

@ -18,7 +18,7 @@ public:
BOOL InitInstance() override;
BOOL ExitInstance() override;
IGameServerConsole* InitializeDialog(HWND hWndParent, IComponentContainer* container);
IGameServerConsole* InitializeDialog(IComponentContainer* container);
DECLARE_MESSAGE_MAP()
};

View File

@ -2,6 +2,7 @@
#include "ServerConsoleApp.h"
#include "ServerDialog.h"
#include "Utils.h"
IMPLEMENT_DYNAMIC(ServerDialog, CDialogEx)
@ -109,10 +110,9 @@ void ServerDialog::OnCancel()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
KillTimer((UINT_PTR)this);
ShowWindow(SW_HIDE);
DestroyWindow();
KillTimer((UINT_PTR)this);
m_pParentWnd->SendMessage(WM_CLOSE, 0, 0);
}
void ServerDialog::RefreshPlayers()

View File

@ -14,7 +14,7 @@ class ServerDialog : public CDialogEx, public ComponentBase<IGameServerConsole>
public:
~ServerDialog();
ServerDialog(IComponentContainer* container, CWnd* parent);
ServerDialog(IComponentContainer* container, CWnd* parent = nullptr);
void CreateColumns();
void RefreshPlayers();

View File

@ -0,0 +1,12 @@
#include "pch.h"
#include <codecvt>
#include "Utils.h"
std::wstring to_wstring(const std::string_view& sourceString)
{
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
return converter.from_bytes(sourceString.data());
}

View File

@ -0,0 +1,5 @@
#pragma once
#include <string>
std::wstring to_wstring(const std::string_view& sourceString);