Text rendering properly deals with newline characters. Updated components that were not properly rendering.

pull/28/head
sigonasr2 11 months ago
parent 5d1e0b5a7a
commit c795e7f891
  1. 4
      Crawler/CharacterMenuWindow.cpp
  2. 21
      Crawler/Crawler.cpp
  3. 8
      Crawler/Crawler.h
  4. 2
      Crawler/Version.h
  5. 18
      Crawler/olcPixelGameEngine.h
  6. BIN
      Crawler/pge.data
  7. 2
      Crawler/pge.js
  8. BIN
      Crawler/pge.wasm

@ -109,7 +109,7 @@ void Menu::InitializeCharacterMenuWindow(){
for(int i=0;i<8;i++){ for(int i=0;i<8;i++){
float x=31+(i%2)*33; float x=31+(i%2)*33;
float y=24+(i/2)*28; float y=24+(i/2)*28;
float labelX=2+(i%2)*90; float labelX=0+(i%2)*88;
float labelY=24+(i/2)*28+36; float labelY=24+(i/2)*28+36;
if(i<6){ if(i<6){
y-=8; y-=8;
@ -234,7 +234,7 @@ void Menu::InitializeCharacterMenuWindow(){
equipmentSlot->SetShowQuantity(false); equipmentSlot->SetShowQuantity(false);
equipmentSlot->SetCompactDescriptions(false); equipmentSlot->SetCompactDescriptions(false);
equipSlot<<=1; equipSlot<<=1;
characterMenuWindow->ADD("Equip Label "+slotNames[i],PopupMenuLabel)({{labelX,labelY},{29,16}},slotNames[i],{0.5,1},ComponentAttr::SHADOW)END; characterMenuWindow->ADD("Equip Label "+slotNames[i],PopupMenuLabel)({{labelX,labelY},{24,16}},slotNames[i],{0.5,1},ComponentAttr::SHADOW)END;
Menu::AddEquipStatListener(equipmentSlot); Menu::AddEquipStatListener(equipmentSlot);
} }

@ -68,7 +68,7 @@ All rights reserved.
#include "MenuItemItemButton.h" #include "MenuItemItemButton.h"
#include "Merchant.h" #include "Merchant.h"
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
#include "discord-files/discord.h" #include "discord.h"
#endif #endif
INCLUDE_EMITTER_LIST INCLUDE_EMITTER_LIST
@ -209,8 +209,9 @@ bool Crawler::OnUserCreate(){
utils::datafile::INITIAL_SETUP_COMPLETE=true; utils::datafile::INITIAL_SETUP_COMPLETE=true;
ValidateGameStatus(); //Checks to make sure everything has been initialized properly. ValidateGameStatus(); //Checks to make sure everything has been initialized properly.
#ifndef __EMSCRIPTEN__
SetupDiscord(); SetupDiscord();
#endif
return true; return true;
} }
@ -2301,22 +2302,22 @@ void Crawler::EndGame(){
gameEnd=true; gameEnd=true;
} }
::discord::Result Crawler::SetupDiscord(){ #ifndef __EMSCRIPTEN__
#ifndef __EMSCRIPTEN__ ::discord::Result Crawler::SetupDiscord(){
auto result=::discord::Core::Create(1186719371750555780,DiscordCreateFlags_NoRequireDiscord,&Discord); auto result=::discord::Core::Create(1186719371750555780,DiscordCreateFlags_NoRequireDiscord,&Discord);
if(result==::discord::Result::Ok){ if(result==::discord::Result::Ok){
Discord->SetLogHook( Discord->SetLogHook(
discord::LogLevel::Debug, [](discord::LogLevel level, const char* message) { discord::LogLevel::Debug, [](discord::LogLevel level, const char* message) {
std::cerr << "Log(" << static_cast<uint32_t>(level) << "): " << message << "\n"; std::cerr << "Log(" << static_cast<uint32_t>(level) << "): " << message << "\n";
}); });
std::cout<<"Connected to Discord!"<<std::endl; std::cout<<"Connected to Discord!"<<std::endl;
UpdateDiscordStatus("Main Menu",player.get()->GetClassName()); UpdateDiscordStatus("Main Menu",player.get()->GetClassName());
}else{ }else{
std::cout<<"Could not connect to Discord. Error Code "<<int(result)<<std::endl; std::cout<<"Could not connect to Discord. Error Code "<<int(result)<<std::endl;
} }
return result; return result;
#endif }
} #endif
void Crawler::UpdateDiscordStatus(std::string levelName,std::string className){ void Crawler::UpdateDiscordStatus(std::string levelName,std::string className){
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__

@ -50,7 +50,9 @@ All rights reserved.
#include "olcUTIL_DataFile.h" #include "olcUTIL_DataFile.h"
#include "Key.h" #include "Key.h"
#include "GameState.h" #include "GameState.h"
#include "discord.h" #ifndef __EMSCRIPTEN__
#include "discord.h"
#endif
class Crawler : public olc::PixelGameEngine class Crawler : public olc::PixelGameEngine
{ {
@ -114,7 +116,9 @@ private:
time_t gameStarted; time_t gameStarted;
void ValidateGameStatus(); void ValidateGameStatus();
::discord::Result SetupDiscord(); #ifndef __EMSCRIPTEN__
::discord::Result SetupDiscord();
#endif
public: public:
Crawler(); Crawler();
bool OnUserCreate() override; bool OnUserCreate() override;

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 1 #define VERSION_PATCH 1
#define VERSION_BUILD 4434 #define VERSION_BUILD 4446
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -3641,6 +3641,9 @@ namespace olc
if (c == '\n') if (c == '\n')
{ {
planningMarker.x = 0; planningMarker.y += 8.0f; planningMarker.x = 0; planningMarker.y += 8.0f;
drawingMarker.x+=lettersWidth;
maxWidth=std::max(maxWidth,drawingMarker.x);
drawingMarker.x = 0; drawingMarker.y += 8.0f;
} }
else if (c == ' ') else if (c == ' ')
{ {
@ -3757,6 +3760,12 @@ namespace olc
if (c == '\n') if (c == '\n')
{ {
planningMarker.x = 0; planningMarker.y += 8.0f * scale; planningMarker.x = 0; planningMarker.y += 8.0f * scale;
for(PixelGameEngine::StringDecalData&letter:letters){
DrawPartialSprite(vi2d(pos + drawingMarker), fontRenderable.Sprite(), vi2d(letter.sourcePos), vi2d(letter.sourceSize), scale, Sprite::Flip::NONE,letter.col);
drawingMarker.x += 8.0f * scale;
}
letters.clear();
drawingMarker.x = 0; drawingMarker.y += 8.0f * scale;
} }
else if (c == ' ') else if (c == ' ')
{ {
@ -3888,6 +3897,9 @@ namespace olc
if (c == '\n') if (c == '\n')
{ {
planningMarker.x = 0; planningMarker.y += 8.0f; planningMarker.x = 0; planningMarker.y += 8.0f;
drawingMarker.x+=lettersWidth;
maxWidth=std::max(maxWidth,drawingMarker.x);
drawingMarker.x=0;drawingMarker.y+=8.0f;
} }
else if (c == ' ') else if (c == ' ')
{ {
@ -3978,6 +3990,12 @@ namespace olc
if (c == '\n') if (c == '\n')
{ {
planningMarker.x = 0; planningMarker.y += 8.0f * scale; planningMarker.x = 0; planningMarker.y += 8.0f * scale;
for(PixelGameEngine::StringDecalData&letter:letters){
DrawPartialSprite(vi2d(pos + drawingMarker), GetFontSprite(), vi2d(letter.sourcePos), vi2d(letter.sourceSize), scale,Sprite::Flip::NONE, letter.col);
drawingMarker.x += float(vFontSpacing[letter.c - 32].y) * scale;
}
letters.clear();
drawingMarker.x = 0; drawingMarker.y += 8.0f * scale;
} }
else if (c == ' ') else if (c == ' ')
{ {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 MiB

After

Width:  |  Height:  |  Size: 10 MiB

File diff suppressed because one or more lines are too long

Binary file not shown.
Loading…
Cancel
Save