bool PackedCol_TryParseHex(STRING_PURE String* str, PackedCol* value) { PackedCol empty = PACKEDCOL_CONST(0, 0, 0, 0); *value = empty; /* accept XXYYZZ or #XXYYZZ forms */ if (str->length < 6) return false; if (str->length > 6 && (str->buffer[0] != '#' || str->length > 7)) return false; Int32 rH, rL, gH, gL, bH, bL; UInt8* buffer = str->buffer; if (buffer[0] == '#') buffer++; if (!PackedCol_Unhex(buffer[0], &rH) || !PackedCol_Unhex(buffer[1], &rL)) return false; if (!PackedCol_Unhex(buffer[2], &gH) || !PackedCol_Unhex(buffer[3], &gL)) return false; if (!PackedCol_Unhex(buffer[4], &bH) || !PackedCol_Unhex(buffer[5], &bL)) return false; value->R = ((rH << 4) | rL); value->G = ((gH << 4) | gL); value->B = ((bH << 4) | bL); value->A = UInt8_MaxValue; return true; }
#include "PickedPosRenderer.h" #include "PackedCol.h" #include "VertexStructs.h" #include "GraphicsAPI.h" #include "GraphicsCommon.h" #include "Game.h" #include "Event.h" GfxResourceID pickedPos_vb; PackedCol pickedPos_col = PACKEDCOL_CONST(0, 0, 0, 102); #define pickedPos_numVertices (16 * 6) VertexP3fC4b pickedPos_vertices[pickedPos_numVertices]; VertexP3fC4b* pickedPos_ptr; static void PickedPosRenderer_ContextLost(void* obj) { Gfx_DeleteVb(&pickedPos_vb); } static void PickedPosRenderer_ContextRecreated(void* obj) { pickedPos_vb = Gfx_CreateDynamicVb(VERTEX_FORMAT_P3FC4B, pickedPos_numVertices); } static void PickedPosRenderer_Init(void) { PickedPosRenderer_ContextRecreated(NULL); Event_RegisterVoid(&GfxEvents_ContextLost, NULL, PickedPosRenderer_ContextLost); Event_RegisterVoid(&GfxEvents_ContextRecreated, NULL, PickedPosRenderer_ContextRecreated); } static void PickedPosRenderer_Free(void) { PickedPosRenderer_ContextLost(NULL); Event_UnregisterVoid(&GfxEvents_ContextLost, NULL, PickedPosRenderer_ContextLost);
} /*########################################################################################################################* *-------------------------------------------------------Environment-------------------------------------------------------* *#########################################################################################################################*/ #define Env_Set(src, dst, var) \ if (src != dst) { dst = src; Event_RaiseInt(&WorldEvents.EnvVarChanged, var); } #define Env_SetCol(src, dst, var)\ if (!PackedCol_Equals(src, dst)) { dst = src; Event_RaiseInt(&WorldEvents.EnvVarChanged, var); } struct _EnvData Env; const char* Weather_Names[3] = { "Sunny", "Rainy", "Snowy" }; const PackedCol Env_DefaultSkyCol = PACKEDCOL_CONST(0x99, 0xCC, 0xFF, 0xFF); const PackedCol Env_DefaultFogCol = PACKEDCOL_CONST(0xFF, 0xFF, 0xFF, 0xFF); const PackedCol Env_DefaultCloudsCol = PACKEDCOL_CONST(0xFF, 0xFF, 0xFF, 0xFF); const PackedCol Env_DefaultSkyboxCol = PACKEDCOL_CONST(0xFF, 0xFF, 0xFF, 0xFF); const PackedCol Env_DefaultSunCol = PACKEDCOL_CONST(0xFF, 0xFF, 0xFF, 0xFF); const PackedCol Env_DefaultShadowCol = PACKEDCOL_CONST(0x9B, 0x9B, 0x9B, 0xFF); static char World_TextureUrlBuffer[STRING_SIZE]; String World_TextureUrl = String_FromArray(World_TextureUrlBuffer); void Env_Reset(void) { Env.EdgeHeight = -1; Env.SidesOffset = -2; Env.CloudsHeight = -1; Env.EdgeBlock = BLOCK_STILL_WATER;