mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
C client: URL clicking works on linux now
This commit is contained in:
parent
efca06111f
commit
630a43bea2
@ -72,11 +72,12 @@ namespace ClassicalSharp.Entities {
|
||||
static void DrawSquareShadow(VertexP3fT2fC4b[] verts, ref int index,
|
||||
float y, float x, float z) {
|
||||
PackedCol col = new PackedCol(c, c, c, (byte)220);
|
||||
TextureRec rec = new TextureRec(63/128f, 63/128f, 1/128f, 1/128f);
|
||||
verts[index++] = new VertexP3fT2fC4b(x, y, z, rec.U1, rec.V1, col);
|
||||
verts[index++] = new VertexP3fT2fC4b(x + 1, y, z, rec.U2, rec.V1, col);
|
||||
verts[index++] = new VertexP3fT2fC4b(x + 1, y, z + 1, rec.U2, rec.V2, col);
|
||||
verts[index++] = new VertexP3fT2fC4b(x, y, z + 1, rec.U1, rec.V2, col);
|
||||
const float uv1 = 63/128f, uv2 = 64/128f;
|
||||
|
||||
verts[index++] = new VertexP3fT2fC4b(x, y, z, uv1, uv1, col);
|
||||
verts[index++] = new VertexP3fT2fC4b(x + 1, y, z, uv2, uv1, col);
|
||||
verts[index++] = new VertexP3fT2fC4b(x + 1, y, z + 1, uv2, uv2, col);
|
||||
verts[index++] = new VertexP3fT2fC4b(x, y, z + 1, uv1, uv2, col);
|
||||
}
|
||||
|
||||
static void DrawCircle(VertexP3fT2fC4b[] verts, ref int index,
|
||||
|
@ -65,6 +65,7 @@ struct FontDesc { void* Handle; UInt16 Size, Style; };
|
||||
#define CC_BUILD_WIN true
|
||||
#define CC_BUILD_OSX false
|
||||
#define CC_BUILD_NIX false
|
||||
#define CC_BUILD_SOLARIS false
|
||||
|
||||
#if CC_BUILD_D3D9
|
||||
typedef void* GfxResourceID;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "GraphicsAPI.h"
|
||||
#if CC_BUILD_D3D9
|
||||
#include "ErrorHandler.h"
|
||||
#include "Platform.h"
|
||||
#include "Window.h"
|
||||
@ -6,8 +7,13 @@
|
||||
#include "Funcs.h"
|
||||
#include "Game.h"
|
||||
|
||||
#if CC_BUILD_D3D9
|
||||
//#define D3D_DISABLE_9EX causes compile errors
|
||||
#if CC_BUILD_WIN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOSERVICE
|
||||
#define NOMCX
|
||||
#define NOIME
|
||||
#endif
|
||||
#include <d3d9.h>
|
||||
#include <d3d9caps.h>
|
||||
#include <d3d9types.h>
|
||||
|
@ -496,14 +496,14 @@ static void ShadowComponent_DrawCoords(VertexP3fT2fC4b** vertices, struct Entity
|
||||
|
||||
static void ShadowComponent_DrawSquareShadow(VertexP3fT2fC4b** vertices, Real32 y, Real32 x, Real32 z) {
|
||||
PackedCol col = PACKEDCOL_CONST(255, 255, 255, 220);
|
||||
struct TextureRec rec = { 63.0f / 128.0f, 63.0f / 128.0f, 64.0f / 128.0f, 64.0f / 128.0f };
|
||||
Real32 uv1 = 63/128.0f, uv2 = 64/128.0f;
|
||||
VertexP3fT2fC4b* ptr = *vertices;
|
||||
VertexP3fT2fC4b v; v.Y = y; v.Col = col;
|
||||
|
||||
v.X = x; v.Z = z; v.U = rec.U1; v.V = rec.V1; *ptr = v; ptr++;
|
||||
v.X = x + 1.0f; v.U = rec.U2; *ptr = v; ptr++;
|
||||
v.Z = z + 1.0f; v.V = rec.V2; *ptr = v; ptr++;
|
||||
v.X = x; v.U = rec.U1; *ptr = v; ptr++;
|
||||
v.X = x; v.Z = z; v.U = uv1; v.V = uv1; *ptr = v; ptr++;
|
||||
v.X = x + 1.0f; v.U = uv2; *ptr = v; ptr++;
|
||||
v.Z = z + 1.0f; v.V = uv2; *ptr = v; ptr++;
|
||||
v.X = x; v.U = uv1; *ptr = v; ptr++;
|
||||
|
||||
*vertices = ptr;
|
||||
}
|
||||
|
@ -748,7 +748,6 @@ void Game_Run(Int32 width, Int32 height, STRING_REF String* title, struct Displa
|
||||
#include "Builder.h"
|
||||
void AdvLightingBuilder_SetActive(void) { NormalBuilder_SetActive(); }
|
||||
#if CC_BUILD_NIX
|
||||
ReturnCode Platform_StartShell(STRING_PURE String* args) { return 0; }
|
||||
void Waitable_WaitFor(void* handle, UInt32 milliseconds) { }
|
||||
STRING_PURE String Platform_GetCommandLineArgs(void) { return String_MakeNull(); }
|
||||
|
||||
|
@ -82,7 +82,7 @@ Real32 Model_RenderDistance(struct Entity* entity) {
|
||||
pos.Y += AABB_Height(bb) * 0.5f; /* Centre Y coordinate. */
|
||||
Vector3 camPos = Game_CurrentCameraPos;
|
||||
|
||||
Real32 dx = Model_MinDist(camPos.X - pos.X, AABB_Width(bb) * 0.5f);
|
||||
Real32 dx = Model_MinDist(camPos.X - pos.X, AABB_Width(bb) * 0.5f);
|
||||
Real32 dy = Model_MinDist(camPos.Y - pos.Y, AABB_Height(bb) * 0.5f);
|
||||
Real32 dz = Model_MinDist(camPos.Z - pos.Z, AABB_Length(bb) * 0.5f);
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "GraphicsAPI.h"
|
||||
#if !CC_BUILD_D3D9
|
||||
#include "ErrorHandler.h"
|
||||
#include "Platform.h"
|
||||
#include "Window.h"
|
||||
@ -6,18 +7,18 @@
|
||||
#include "Funcs.h"
|
||||
#include "Chat.h"
|
||||
#include "Game.h"
|
||||
|
||||
#if CC_BUILD_WIN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOSERVICE
|
||||
#define NOMCX
|
||||
#define NOIME
|
||||
#if CC_BUILD_WIN
|
||||
#include <windows.h>
|
||||
#else
|
||||
#define APIENETRY
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
|
||||
#if !CC_BUILD_D3D9
|
||||
/* Extensions from later than OpenGL 1.1 */
|
||||
#define GL_TEXTURE_MAX_LEVEL 0x813D
|
||||
#define GL_ARRAY_BUFFER 0x8892
|
||||
|
@ -9,7 +9,6 @@
|
||||
const char* FpsLimit_Names[FpsLimit_Count] = {
|
||||
"LimitVSync", "Limit30FPS", "Limit60FPS", "Limit120FPS", "LimitNone",
|
||||
};
|
||||
#define OPT_NOT_FOUND UInt32_MaxValue
|
||||
StringsBuffer Options_Changed;
|
||||
|
||||
bool Options_HasAnyChanged(void) { return Options_Changed.Count > 0; }
|
||||
@ -29,21 +28,21 @@ bool Options_HasChanged(STRING_PURE String* key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static UInt32 Options_Find(STRING_PURE String* key) {
|
||||
static Int32 Options_Find(STRING_PURE String* key) {
|
||||
Int32 i;
|
||||
for (i = 0; i < Options_Keys.Count; i++) {
|
||||
String curKey = StringsBuffer_UNSAFE_Get(&Options_Keys, i);
|
||||
if (String_CaselessEquals(&curKey, key)) return i;
|
||||
}
|
||||
return OPT_NOT_FOUND;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static bool Options_TryGetValue(const char* keyRaw, STRING_TRANSIENT String* value) {
|
||||
String key = String_FromReadonly(keyRaw);
|
||||
*value = String_MakeNull();
|
||||
|
||||
UInt32 i = Options_Find(&key);
|
||||
if (i != OPT_NOT_FOUND) {
|
||||
Int32 i = Options_Find(&key);
|
||||
if (i >= 0) {
|
||||
*value = StringsBuffer_UNSAFE_Get(&Options_Values, i);
|
||||
return true;
|
||||
}
|
||||
@ -53,7 +52,7 @@ static bool Options_TryGetValue(const char* keyRaw, STRING_TRANSIENT String* val
|
||||
key = String_UNSAFE_SubstringAt(&key, sepIndex + 1);
|
||||
|
||||
i = Options_Find(&key);
|
||||
if (i != OPT_NOT_FOUND) {
|
||||
if (i >= 0) {
|
||||
*value = StringsBuffer_UNSAFE_Get(&Options_Values, i);
|
||||
return true;
|
||||
}
|
||||
@ -107,14 +106,14 @@ UInt32 Options_GetEnum(const char* key, UInt32 defValue, const char** names, UIn
|
||||
return Utils_ParseEnum(&str, defValue, names, namesCount);
|
||||
}
|
||||
|
||||
static void Options_Remove(UInt32 i) {
|
||||
static void Options_Remove(Int32 i) {
|
||||
StringsBuffer_Remove(&Options_Keys, i);
|
||||
StringsBuffer_Remove(&Options_Values, i);
|
||||
}
|
||||
|
||||
static Int32 Options_Insert(STRING_PURE String* key, STRING_PURE String* value) {
|
||||
UInt32 i = Options_Find(key);
|
||||
if (i != OPT_NOT_FOUND) Options_Remove(i);
|
||||
Int32 i = Options_Find(key);
|
||||
if (i >= 0) Options_Remove(i);
|
||||
|
||||
StringsBuffer_Add(&Options_Keys, key);
|
||||
StringsBuffer_Add(&Options_Values, value);
|
||||
@ -142,15 +141,15 @@ void Options_Set(const char* keyRaw, STRING_PURE String* value) {
|
||||
}
|
||||
|
||||
void Options_SetString(STRING_PURE String* key, STRING_PURE String* value) {
|
||||
UInt32 i;
|
||||
Int32 i;
|
||||
if (value == NULL || value->buffer == NULL) {
|
||||
i = Options_Find(key);
|
||||
if (i != OPT_NOT_FOUND) Options_Remove(i);
|
||||
if (i >= 0) Options_Remove(i);
|
||||
} else {
|
||||
i = Options_Insert(key, value);
|
||||
}
|
||||
|
||||
if (i == OPT_NOT_FOUND || Options_HasChanged(key)) return;
|
||||
if (i == -1 || Options_HasChanged(key)) return;
|
||||
StringsBuffer_Add(&Options_Changed, key);
|
||||
}
|
||||
|
||||
@ -163,11 +162,11 @@ void Options_Load(void) {
|
||||
if (res) { Chat_LogError(res, "opening", &path); return; }
|
||||
|
||||
/* Remove all the unchanged options */
|
||||
UInt32 i;
|
||||
for (i = Options_Keys.Count; i > 0; i--) {
|
||||
String key = StringsBuffer_UNSAFE_Get(&Options_Keys, i - 1);
|
||||
Int32 i;
|
||||
for (i = Options_Keys.Count - 1; i >= 0; i--) {
|
||||
String key = StringsBuffer_UNSAFE_Get(&Options_Keys, i);
|
||||
if (Options_HasChanged(&key)) continue;
|
||||
Options_Remove(i - 1);
|
||||
Options_Remove(i);
|
||||
}
|
||||
|
||||
char lineBuffer[768];
|
||||
|
@ -13,6 +13,8 @@
|
||||
#define NOSERVICE
|
||||
#define NOMCX
|
||||
#define NOIME
|
||||
#define _WIN32_IE 0x0400
|
||||
#define WINVER 0x0500
|
||||
#define _WIN32_WINNT 0x0500
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
@ -53,6 +55,9 @@ ReturnCode ReturnCode_SocketWouldBlock = WSAEWOULDBLOCK;
|
||||
#include <sys/stat.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <curl/curl.h>
|
||||
#if CC_BUILD_SOLARIS
|
||||
#include <sys/filio.h>
|
||||
#endif
|
||||
|
||||
#define Socket__Error() errno
|
||||
#define Nix_Return(success) ((success) ? 0 : errno)
|
||||
@ -153,6 +158,11 @@ void Platform_Log4(const char* format, const void* a1, const void* a2, const voi
|
||||
Platform_Log(&msg);
|
||||
}
|
||||
|
||||
void Platform_LogConst(const char* message) {
|
||||
String msg = String_FromReadonly(message);
|
||||
Platform_Log(&msg);
|
||||
}
|
||||
|
||||
/* TODO: check this is actually accurate */
|
||||
UInt64 sw_freqMul = 1, sw_freqDiv = 1;
|
||||
Int32 Stopwatch_ElapsedMicroseconds(UInt64* timer) {
|
||||
@ -172,12 +182,6 @@ void Platform_Log(STRING_PURE String* message) {
|
||||
OutputDebugStringA("\n");
|
||||
}
|
||||
|
||||
void Platform_LogConst(const char* message) {
|
||||
/* TODO: log to console */
|
||||
OutputDebugStringA(message);
|
||||
OutputDebugStringA("\n");
|
||||
}
|
||||
|
||||
#define FILETIME_EPOCH 50491123200000ULL
|
||||
#define FileTime_TotalMS(time) ((time / 10000) + FILETIME_EPOCH)
|
||||
UInt64 DateTime_CurrentUTC_MS(void) {
|
||||
@ -222,8 +226,9 @@ void Stopwatch_Measure(UInt64* timer) {
|
||||
}
|
||||
}
|
||||
#elif CC_BUILD_NIX
|
||||
void Platform_Log(STRING_PURE String* message) { puts(message->buffer); }
|
||||
void Platform_LogConst(const char* message) { puts(message); }
|
||||
void Platform_Log(STRING_PURE String* message) {
|
||||
puts(message->buffer);
|
||||
}
|
||||
|
||||
#define UNIX_EPOCH 62135596800000ULL
|
||||
#define UnixTime_TotalMS(time) ((UInt64)time.tv_sec * 1000 + UNIX_EPOCH + (time.tv_usec / 1000))
|
||||
@ -1354,4 +1359,15 @@ void Platform_SetWorkingDir(void) {
|
||||
}
|
||||
|
||||
void Platform_Exit(ReturnCode code) { exit(code); }
|
||||
|
||||
ReturnCode Platform_StartShell(STRING_PURE String* args) {
|
||||
char pathBuffer[FILENAME_SIZE + 10];
|
||||
String path = String_FromArray(pathBuffer);
|
||||
String_Format1(&path, "xdg-open %s", args);
|
||||
char str[300]; Platform_ConvertString(str, &path);
|
||||
|
||||
FILE* fp = popen(str, "r");
|
||||
if (!fp) return errno;
|
||||
return Nix_Return(pclose(fp));
|
||||
}
|
||||
#endif
|
||||
|
@ -29,11 +29,12 @@ UInt16 String_CalcLen(STRING_PURE const char* raw, UInt16 capacity);
|
||||
String String_MakeNull(void);
|
||||
String String_Init(STRING_REF char* buffer, UInt16 length, UInt16 capacity);
|
||||
String String_InitAndClear(STRING_REF char* buffer, UInt16 capacity);
|
||||
#define String_ClearedArray(buffer) String_InitAndClear(buffer, (UInt16)sizeof(buffer))
|
||||
/* Constructs a new string from a (maybe null terminated) buffer. */
|
||||
String String_FromRaw(STRING_REF char* buffer, UInt16 capacity);
|
||||
NOINLINE_ String String_FromRaw(STRING_REF char* buffer, UInt16 capacity);
|
||||
/* Constructs a new string from a null-terminated constant readonly buffer. */
|
||||
String String_FromReadonly(STRING_REF const char* buffer);
|
||||
NOINLINE_ String String_FromReadonly(STRING_REF const char* buffer);
|
||||
|
||||
#define String_ClearedArray(buffer) String_InitAndClear(buffer, (UInt16)sizeof(buffer))
|
||||
/* Constructs a new string from a compile time string constant. */
|
||||
#define String_FromConst(text) { text, (UInt16)(sizeof(text) - 1), (UInt16)(sizeof(text) - 1)}
|
||||
/* Constructs a new string from a compile time empty string buffer. */
|
||||
|
@ -4,10 +4,13 @@
|
||||
#include "Input.h"
|
||||
#include "Event.h"
|
||||
#include "ErrorHandler.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOSERVICE
|
||||
#define NOMCX
|
||||
#define NOIME
|
||||
#define _WIN32_IE 0x0400
|
||||
#define WINVER 0x0500
|
||||
#define _WIN32_WINNT 0x0500
|
||||
#include <windows.h>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user