D
Deleted User
Guest
OP
I am making a simple program and I wish to implement scrolling text via the Dpad my origanal idea is to do this
this works for scrolling up but not down I was wondering if I am aproaching this wrong or if there is a way to to insert text at the very top of the screen any suggestions would be great thanks -Ryu
Code:
// T3xt-v1.0
#include <iostream>
#include <fstream>
#include <string>
#include <3ds.h>
using namespace std;
int main()
{
gfxInitDefault();
PrintConsole topScreen, bottomScreen;
consoleInit(GFX_TOP, &topScreen);
consoleInit(GFX_BOTTOM, &bottomScreen);
consoleSelect(&bottomScreen);
cout << endl;
cout << "T3xt-v1.0" << endl;
cout << endl;
cout << "[A] Edit:" << endl;
cout << endl;
cout << "[B] Save:" << endl;
cout << endl;
cout << "[Y] Open:" << endl;
cout << endl;
cout << "[UP/DOWN] Scroll:" << endl;
cout << endl;
consoleSelect(&topScreen);
while (aptMainLoop())
{
hidScanInput();
u32 kHeld = hidKeysHeld();
u32 kDown = hidKeysDown();
static SwkbdState swkbd;
static char Edit[999999];
static char Save[999999];
static char Open[999999];
SwkbdButton button = SWKBD_BUTTON_NONE;
if (kDown & KEY_A)
{
swkbdInit(&swkbd, SWKBD_TYPE_NORMAL, 2, -1);
swkbdSetHintText(&swkbd, "Edit:");
button = swkbdInputText(&swkbd, Edit, sizeof(Edit));
cout << Edit << endl;
}
if (kDown & KEY_B)
{
swkbdInit(&swkbd, SWKBD_TYPE_NORMAL, 2, -1);
swkbdSetHintText(&swkbd, "Save:");
button = swkbdInputText(&swkbd, Save, sizeof(Save));
ofstream MyFile (Save);
if (MyFile.is_open())
{
MyFile << Edit;
MyFile.close();
}
}
if (kDown & KEY_Y)
{
swkbdInit(&swkbd, SWKBD_TYPE_NORMAL, 2, -1);
swkbdSetHintText(&swkbd, "Open:");
button = swkbdInputText(&swkbd, Open, sizeof(Open));
string Output = "";
ifstream MyFile (Open);
if (MyFile.is_open())
{
while ( getline (MyFile,Output) )
{
cout << Output << endl;
}
MyFile.close();
}
}
if (kHeld & KEY_UP)
{
cout << endl;
}
if (kHeld & KEY_DOWN)
{
cout << endl;
}
if (kDown & KEY_START)
{
break;
}
gfxFlushBuffers();
gfxSwapBuffers();
gspWaitForVBlank();
}
gfxExit();
return 0;
}
this works for scrolling up but not down I was wondering if I am aproaching this wrong or if there is a way to to insert text at the very top of the screen any suggestions would be great thanks -Ryu
Last edited by ,