Comment tweaks, build tweaks, bugfixes
I've also disabled the "screen trick". It was ugly as hell.
This commit is contained in:
@@ -48,7 +48,7 @@ public:
|
|||||||
virtual void KeyDown(SDL_KeyboardEvent const& event);
|
virtual void KeyDown(SDL_KeyboardEvent const& event);
|
||||||
virtual void KeyUp(SDL_KeyboardEvent const& event);
|
virtual void KeyUp(SDL_KeyboardEvent const& event);
|
||||||
|
|
||||||
//TODO: joystick and controller events
|
//TODO: (9) joystick and controller events
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//control
|
//control
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ void ClientApplication::Init(int argc, char* argv[]) {
|
|||||||
//get the info
|
//get the info
|
||||||
switch(windowInfo.subsystem) {
|
switch(windowInfo.subsystem) {
|
||||||
case SDL_SYSWM_WINDOWS:
|
case SDL_SYSWM_WINDOWS:
|
||||||
//TODO: ensure that this works
|
|
||||||
platform = "Microsoft Windows";
|
platform = "Microsoft Windows";
|
||||||
fontPath = "C:/Windows/Fonts/arialbd.ttf";
|
fontPath = "C:/Windows/Fonts/arialbd.ttf";
|
||||||
break;
|
break;
|
||||||
@@ -296,7 +295,7 @@ void ClientApplication::ProcessEvents() {
|
|||||||
activeScene->KeyUp(event.key);
|
activeScene->KeyUp(event.key);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//TODO: joystick and controller events
|
//TODO: (9) joystick and controller events
|
||||||
|
|
||||||
//window events are handled internally
|
//window events are handled internally
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ private:
|
|||||||
|
|
||||||
BaseScene* activeScene = nullptr;
|
BaseScene* activeScene = nullptr;
|
||||||
|
|
||||||
//TODO: build a "window" class?
|
//TODO: (9) build a "window" class?
|
||||||
SDL_Window* window = nullptr;
|
SDL_Window* window = nullptr;
|
||||||
SDL_Renderer* renderer = nullptr;
|
SDL_Renderer* renderer = nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#include "text_util.hpp"
|
|
||||||
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
SDL_Texture* renderPlainText(SDL_Renderer* renderer, TTF_Font* font, std::string str, SDL_Color color) {
|
|
||||||
//make the surface (from SDL_ttf)
|
|
||||||
SDL_Surface* surface = TTF_RenderText_Solid(font, str.c_str(), color);
|
|
||||||
if (!surface) {
|
|
||||||
throw(std::runtime_error("Failed to create a TTF surface"));
|
|
||||||
}
|
|
||||||
|
|
||||||
//convert to texture
|
|
||||||
SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface);
|
|
||||||
if (!texture) {
|
|
||||||
SDL_FreeSurface(surface);
|
|
||||||
throw(std::runtime_error("Failed to create a TTF texture"));
|
|
||||||
}
|
|
||||||
|
|
||||||
//cleanup
|
|
||||||
SDL_FreeSurface(surface);
|
|
||||||
|
|
||||||
//NOTE: free the texture yourself
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "SDL2/SDL.h"
|
|
||||||
#include "SDL2/SDL_ttf.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
constexpr SDL_Color COLOR_WHITE = {255, 255, 255, 255};
|
|
||||||
|
|
||||||
//TODO: some kind of persistent display widget
|
|
||||||
//TODO: I need a full suite of widgets
|
|
||||||
SDL_Texture* renderPlainText(SDL_Renderer*, TTF_Font*, std::string, SDL_Color color);
|
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "base_character.hpp"
|
#include "base_character.hpp"
|
||||||
|
|
||||||
//TODO: remove this
|
//TODO: (3) remove this
|
||||||
#include "config_utility.hpp"
|
#include "config_utility.hpp"
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include "vector2.hpp"
|
#include "vector2.hpp"
|
||||||
|
|
||||||
//The base class for all objects in the world
|
//The base class for all objects in the world
|
||||||
//TODO: write a better hierarchy
|
//TODO: (9) write a better hierarchy
|
||||||
class Entity {
|
class Entity {
|
||||||
public:
|
public:
|
||||||
virtual void Update();
|
virtual void Update();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
bool LocalCharacter::ProcessCollisionGrid(std::list<BoundingBox> boxList) {
|
bool LocalCharacter::ProcessCollisionGrid(std::list<BoundingBox> boxList) {
|
||||||
for(auto& box : boxList) {
|
for(auto& box : boxList) {
|
||||||
if (box.CheckOverlap(origin + bounds)) {
|
if (box.CheckOverlap(origin + bounds)) {
|
||||||
//TODO: write a better collision system
|
//TODO: (9) write a better collision system
|
||||||
origin -= motion;
|
origin -= motion;
|
||||||
motion = {0, 0};
|
motion = {0, 0};
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -223,8 +223,7 @@ std::list<BoundingBox> World::GenerateCollisionGrid(Entity* ptr, int tileWidth,
|
|||||||
//inner loop
|
//inner loop
|
||||||
wallBounds.y = snapToBase((double)wallBounds.h, ptr->GetOrigin().y);
|
wallBounds.y = snapToBase((double)wallBounds.h, ptr->GetOrigin().y);
|
||||||
while(wallBounds.y < (ptr->GetOrigin() + ptr->GetBounds()).y + ptr->GetBounds().h) {
|
while(wallBounds.y < (ptr->GetOrigin() + ptr->GetBounds()).y + ptr->GetBounds().h) {
|
||||||
//BUG: #45 this is the culprit; it's pulling regions into existance
|
//check to see if this tile is solid (non-existant tiles are always false)
|
||||||
//check to see if this tile is solid
|
|
||||||
if (regionPager.GetSolid(wallBounds.x / wallBounds.w, wallBounds.y / wallBounds.h)) {
|
if (regionPager.GetSolid(wallBounds.x / wallBounds.w, wallBounds.y / wallBounds.h)) {
|
||||||
//push onto the box set
|
//push onto the box set
|
||||||
boxList.push_front(wallBounds);
|
boxList.push_front(wallBounds);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
//static functions
|
//static functions
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
//TODO: proper checksum
|
//TODO: (3) proper checksum
|
||||||
static int regionChecksum(Region* const region) {
|
static int regionChecksum(Region* const region) {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for(int i = 0; i < REGION_WIDTH; i++) {
|
for(int i = 0; i < REGION_WIDTH; i++) {
|
||||||
@@ -104,7 +104,6 @@ void World::UpdateMap() {
|
|||||||
}
|
}
|
||||||
else if (regionChecksum(region) == 0) {
|
else if (regionChecksum(region) == 0) {
|
||||||
//checksum failed
|
//checksum failed
|
||||||
//BUG: #45 Regions occasionally lose their tile data; this patches the issue, but does not resolve it
|
|
||||||
regionPager.UnloadIf([region](Region const& ref) -> bool {
|
regionPager.UnloadIf([region](Region const& ref) -> bool {
|
||||||
//remove the erroneous region
|
//remove the erroneous region
|
||||||
return region == &ref;
|
return region == &ref;
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ void LobbyMenu::SendJoinRequest() {
|
|||||||
|
|
||||||
void LobbyMenu::SendLoginRequest() {
|
void LobbyMenu::SendLoginRequest() {
|
||||||
//NOTE: high cohesion
|
//NOTE: high cohesion
|
||||||
//TODO: have a separate login screen
|
//TODO: (9) have a separate login screen
|
||||||
ClientPacket packet;
|
ClientPacket packet;
|
||||||
packet.type = SerialPacketType::LOGIN_REQUEST;
|
packet.type = SerialPacketType::LOGIN_REQUEST;
|
||||||
packet.clientIndex = clientIndex;
|
packet.clientIndex = clientIndex;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ MainMenu::MainMenu() {
|
|||||||
//text box
|
//text box
|
||||||
textBox.PushLine(GetRenderer(), font, "Thanks for playing!", {255, 255, 255, 255});
|
textBox.PushLine(GetRenderer(), font, "Thanks for playing!", {255, 255, 255, 255});
|
||||||
textBox.PushLine(GetRenderer(), font, "You can get the latest version at: ", {255, 255, 255, 255});
|
textBox.PushLine(GetRenderer(), font, "You can get the latest version at: ", {255, 255, 255, 255});
|
||||||
textBox.PushLine(GetRenderer(), font, "krgamestudios.com", {255, 255, 255, 255}); //TODO: click to open the website/update
|
textBox.PushLine(GetRenderer(), font, "krgamestudios.com", {255, 255, 255, 255}); //TODO: (9) click to open the website/update
|
||||||
|
|
||||||
//debug
|
//debug
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -29,21 +29,21 @@
|
|||||||
|
|
||||||
SplashScreen::SplashScreen(SDL_Window* w) {
|
SplashScreen::SplashScreen(SDL_Window* w) {
|
||||||
//fit the screen to the logo
|
//fit the screen to the logo
|
||||||
//TODO: refactor the code for this window trick
|
//NOTE: not using this window trick
|
||||||
window = w;
|
window = w;
|
||||||
SDL_GetWindowSize(window, &windowWidth, &windowHeight);
|
SDL_GetWindowSize(window, &windowWidth, &windowHeight);
|
||||||
|
|
||||||
logo.Load(GetRenderer(), ConfigUtility::GetSingleton()["dir.logos"] + "krstudios.png");
|
logo.Load(GetRenderer(), ConfigUtility::GetSingleton()["dir.logos"] + "krstudios.png");
|
||||||
|
|
||||||
SDL_SetWindowSize(window, logo.GetClipW(), logo.GetClipH());
|
// SDL_SetWindowSize(window, logo.GetClipW(), logo.GetClipH());
|
||||||
SDL_RenderSetLogicalSize(GetRenderer(), logo.GetClipW(), logo.GetClipH());
|
// SDL_RenderSetLogicalSize(GetRenderer(), logo.GetClipW(), logo.GetClipH());
|
||||||
|
|
||||||
startTick = std::chrono::steady_clock::now();
|
startTick = std::chrono::steady_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
SplashScreen::~SplashScreen() {
|
SplashScreen::~SplashScreen() {
|
||||||
SDL_SetWindowSize(window, windowWidth, windowHeight);
|
// SDL_SetWindowSize(window, windowWidth, windowHeight);
|
||||||
SDL_RenderSetLogicalSize(GetRenderer(), windowWidth, windowHeight);
|
// SDL_RenderSetLogicalSize(GetRenderer(), windowWidth, windowHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
@@ -51,7 +51,7 @@ SplashScreen::~SplashScreen() {
|
|||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
void SplashScreen::FrameStart() {
|
void SplashScreen::FrameStart() {
|
||||||
//TODO: config flag to change the delay
|
//TODO: (0) config flag to change the delay
|
||||||
if (std::chrono::steady_clock::now() - startTick > std::chrono::duration<int>(3)) {
|
if (std::chrono::steady_clock::now() - startTick > std::chrono::duration<int>(3)) {
|
||||||
SetSceneSignal(SceneSignal::MAINMENU);
|
SetSceneSignal(SceneSignal::MAINMENU);
|
||||||
}
|
}
|
||||||
@@ -60,6 +60,5 @@ void SplashScreen::FrameStart() {
|
|||||||
void SplashScreen::RenderFrame(SDL_Renderer* renderer) {
|
void SplashScreen::RenderFrame(SDL_Renderer* renderer) {
|
||||||
int w = 0, h = 0;
|
int w = 0, h = 0;
|
||||||
SDL_RenderGetLogicalSize(renderer, &w, &h);
|
SDL_RenderGetLogicalSize(renderer, &w, &h);
|
||||||
//TODO: fix logo position
|
|
||||||
logo.DrawTo(renderer, (w - logo.GetClipW()) / 2, (h - logo.GetClipH()) / 2);
|
logo.DrawTo(renderer, (w - logo.GetClipW()) / 2, (h - logo.GetClipH()) / 2);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
Submodule common updated: 0c1232ae3b...a083cce5da
@@ -38,10 +38,11 @@ $(OUTDIR):
|
|||||||
clean:
|
clean:
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
del /s *.o *.a *.exe $(OUTDIR)\*.dll
|
del /s *.o *.a *.exe $(OUTDIR)\*.dll
|
||||||
|
rmdir $(OUTDIR)
|
||||||
else ifeq ($(shell uname), Linux)
|
else ifeq ($(shell uname), Linux)
|
||||||
find . -type f -name '*.o' -exec rm -f -r -v {} \;
|
find . -type f -name '*.o' -exec rm -f -r -v {} \;
|
||||||
find . -type f -name '*.a' -exec rm -f -r -v {} \;
|
find . -type f -name '*.a' -exec rm -f -r -v {} \;
|
||||||
rm -f -v $(OUTDIR)
|
rm $(OUTDIR)/* -f
|
||||||
find . -empty -type d -delete
|
find . -empty -type d -delete
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
#configuration of the programs
|
#configuration of the programs
|
||||||
|
#TODO: (9) split this file in two, one for each program
|
||||||
|
|
||||||
#server specific settings
|
#server specific settings
|
||||||
server.host = 255.255.255.255
|
server.host = 255.255.255.255
|
||||||
@@ -10,7 +11,7 @@ server.dbname = database.db
|
|||||||
#client specific settings
|
#client specific settings
|
||||||
#client.screen.w = 800
|
#client.screen.w = 800
|
||||||
#client.screen.h = 600
|
#client.screen.h = 600
|
||||||
client.screen.f = false
|
#client.screen.f = false #NOTE: fullscreen option is currently disabled
|
||||||
|
|
||||||
#set this to overwrite the default fonts (platform issues)
|
#set this to overwrite the default fonts (platform issues)
|
||||||
#client.font = /path/to/font/file.ttf
|
#client.font = /path/to/font/file.ttf
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ void CharacterManager::Unload(int uid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CharacterManager::Delete(int uid) {
|
void CharacterManager::Delete(int uid) {
|
||||||
//TODO: when deleting a character, move it to an archive table
|
//TODO: (9) when deleting a character, move it to an archive table
|
||||||
//delete this character from the database, then remove it from memory
|
//delete this character from the database, then remove it from memory
|
||||||
sqlite3_stmt* statement = nullptr;
|
sqlite3_stmt* statement = nullptr;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user