Text wrap works now?

This commit is contained in:
J-D-K
2018-06-17 00:51:39 -04:00
parent cdc621fe4f
commit 4433a23609
7 changed files with 32 additions and 13 deletions

View File

@@ -38,7 +38,7 @@ INCLUDES := inc
EXEFS_SRC := exefs_src
APP_TITLE := JKSV
APP_AUTHOR := JK_
APP_VERSION := 06/15/2018
APP_VERSION := 06/17/2018
ROMFS := romfs
#---------------------------------------------------------------------------------
@@ -46,7 +46,7 @@ ROMFS := romfs
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE
CFLAGS := -g -Wall -O3 -ffunction-sections \
CFLAGS := -g -Wall -O2 -ffunction-sections \
$(ARCH) $(DEFINES)
CFLAGS += $(INCLUDE) -D__SWITCH__ `freetype-config --cflags`

View File

@@ -27,6 +27,7 @@ namespace fs
{
public:
dirList(const std::string& _path);
void reassign(const std::string& _path);
void rescan();
std::string getItem(int index);

View File

@@ -20,7 +20,7 @@ namespace gfx
//Blends two pixels. Clr is the color to be drawn. FB should be the framebuffer pixel
uint32_t blend(const uint32_t& clr, const uint32_t& fb);
//Draws text using shared font. No alpha blending yet.
//Draws text using shared font.
void drawText(const std::string& str, unsigned x, unsigned y, const uint32_t& sz, const uint32_t& clr);
//Returns width of str

View File

@@ -55,6 +55,20 @@ namespace fs
closedir(d);
}
void dirList::reassign(const std::string& _path)
{
path = _path;
d = opendir(path.c_str());
while((ent = readdir(d)))
{
item.push_back(ent->d_name);
}
closedir(d);
}
void dirList::rescan()
{
item.clear();

View File

@@ -37,7 +37,7 @@ int main(int argc, const char *argv[])
break;
gfx::clearBufferColor(0x3B3B3BFF);
gfx::drawText("JKSV - 6/15/2018", 16, 16, 64, 0xFFFFFFFF);
gfx::drawText("JKSV - 6/17/2018", 16, 16, 64, 0xFFFFFFFF);
gfx::drawRectangle(16, 64, 1248, 1, 0xFFFFFFFF);
gfx::drawRectangle(448, 64, 1, 592, 0xFFFFFFFF);
gfx::drawRectangle(16, 656, 1248, 1, 0xFFFFFFFF);

View File

@@ -687,8 +687,6 @@ namespace ui
{
if(folderMenu.getSelected() > 0)
{
fs::delDir("sv:/");
std::string scanPath = util::getTitleDir(data::curUser, data::curData);
fs::dirList list(scanPath);
@@ -703,7 +701,7 @@ namespace ui
}
}
else
ui::showMessage("NEIN! NEIN! NEIN!");
ui::showMessage("Writing data to system save data is not allowed currently. It CAN brick your system.");
}
else if(down & KEY_X)
{
@@ -800,6 +798,7 @@ namespace ui
void showMessage(const std::string& mess)
{
button ok("OK (A)", 480, 464, 320, 96);
std::string wrapMess = util::getWrappedString(mess, 48, 752);
while(true)
{
hidScanInput();
@@ -812,7 +811,7 @@ namespace ui
break;
gfx::drawRectangle(256, 128, 768, 464, 0xC0C0C0FF);
gfx::drawText(mess, 272, 144, 48, 0x000000FF);
gfx::drawText(wrapMess, 272, 144, 48, 0x000000FF);
ok.draw();
gfx::handleBuffs();
@@ -823,6 +822,7 @@ namespace ui
{
button ok("OK (A)", 480, 464, 320, 96);
char tmp[512];
std::string wrapMess = util::getWrappedString(mess, 48, 752);
sprintf(tmp, "%s\n0x%08X", mess.c_str(), (unsigned)r);
while(true)
@@ -851,6 +851,8 @@ namespace ui
button yes("Yes (A)", 288, 464, 320, 96);
button no("No (B)", 672, 464, 320, 96);
std::string wrapMess = util::getWrappedString(mess, 48, 752);
while(true)
{
hidScanInput();
@@ -871,7 +873,7 @@ namespace ui
}
gfx::drawRectangle(256, 128, 768, 464, 0xC0C0C0FF);
gfx::drawText(mess, 272, 144, 48, 0x000000FF);
gfx::drawText(wrapMess, 272, 144, 48, 0x000000FF);
yes.draw();
no.draw();

View File

@@ -56,14 +56,16 @@ namespace util
{
tmp.assign(s, first, lastSpace - first);
first = lastSpace + 1;
ret += tmp + "\n";
tmp.assign(s, first, i);
first = lastSpace + 1;
i = lastSpace;
tmp.clear();
}
else if(i == s.length() - 1 && gfx::getTextWidth(tmp, sz) < maxWidth)
ret += tmp;
}
if(!tmp.empty())
ret += tmp;
return ret;
}