1
0
mirror of https://github.com/ncblakely/GiantsTools synced 2024-11-22 22:25:37 +01:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Nick Blakely
3fc16e8b6b Update SDK and server console example. 2020-12-21 00:38:20 -08:00
Nick Blakely
18fe4087ad Tag debug/beta builds in window title. 2020-12-12 17:41:01 -08:00
13 changed files with 209 additions and 35 deletions

View File

@ -16,7 +16,6 @@ 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";
@ -38,7 +37,7 @@ namespace Giants.Launcher
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
// Set window title
this.Text = GameName;
this.SetTitle();
// Read newer file-based game settings
this.config = new Config();
@ -97,7 +96,7 @@ namespace Giants.Launcher
private void btnOptions_Click(object sender, EventArgs e)
{
OptionsForm form = new OptionsForm(GameName + " Options", this.gamePath);
OptionsForm form = new OptionsForm(Resources.AppName + " Options", this.gamePath);
form.StartPosition = FormStartPosition.CenterParent;
form.ShowDialog();
@ -116,7 +115,7 @@ namespace Giants.Launcher
if (this.gamePath == null || !File.Exists(this.gamePath))
{
string message = string.Format(Resources.AppNotFound, GameName);
string message = string.Format(Resources.AppNotFound, Resources.AppName);
MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
return;
@ -131,7 +130,7 @@ namespace Giants.Launcher
Version gameVersion = VersionHelper.GetGameVersion(this.gamePath);
if (gameVersion == null)
{
string message = string.Format(Resources.AppNotFound, GameName);
string message = string.Format(Resources.AppNotFound, Resources.AppName);
MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
@ -334,6 +333,21 @@ 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,6 +60,15 @@ 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,4 +205,7 @@
<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>

165
Sdk/Include/DataTypes.h Normal file
View File

@ -0,0 +1,165 @@
#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() = 0;
virtual void STDMETHODCALLTYPE DeleteServerInformationAsync(tstring_view gameName, int hostPort) = 0;
virtual ServerInfoFuture STDMETHODCALLTYPE GetServerInformationAsync() = 0;
virtual void STDMETHODCALLTYPE PostServerInformationAsync(const njson& requestBody) = 0;
};

View File

@ -104,6 +104,7 @@
<EnablePREfast>true</EnablePREfast>
<LanguageStandard>stdcpplatest</LanguageStandard>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -158,6 +159,7 @@
<EnablePREfast>true</EnablePREfast>
<LanguageStandard>stdcpplatest</LanguageStandard>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -213,7 +215,6 @@
</ClCompile>
<ClCompile Include="ServerDialog.cpp" />
<ClCompile Include="ServerConsoleApp.cpp" />
<ClCompile Include="Utils.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="res\ServerConsole.rc2" />
@ -226,7 +227,6 @@
<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,5 +1,4 @@
#include "pch.h"
#include <initguid.h>
#include "ServerConsoleApp.h"
#include "ServerDialog.h"
@ -32,18 +31,19 @@ BOOL ServerConsoleApp::ExitInstance()
return CWinApp::ExitInstance();
}
IGameServerConsole* ServerConsoleApp::InitializeDialog(IComponentContainer* container)
IGameServerConsole* ServerConsoleApp::InitializeDialog(HWND hWndParent, 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);
auto* dialog = new ServerDialog(container, CWnd::FromHandle(hWndParent));
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(container);
ConsoleApp.InitializeDialog(hWnd, container);
}

View File

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

View File

@ -2,7 +2,6 @@
#include "ServerConsoleApp.h"
#include "ServerDialog.h"
#include "Utils.h"
IMPLEMENT_DYNAMIC(ServerDialog, CDialogEx)
@ -110,9 +109,10 @@ 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 = nullptr);
ServerDialog(IComponentContainer* container, CWnd* parent);
void CreateColumns();
void RefreshPlayers();

View File

@ -1,12 +0,0 @@
#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

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