Homebrew How to implement scrolling text using C++

  • Thread starter Deleted User
  • Start date
  • Views 2,728
  • Replies 2
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
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 ,

sarkwalvein

There's hope for a Xenosaga port.
Member
Joined
Jun 29, 2007
Messages
8,513
Trophies
2
Age
41
Location
Niedersachsen
XP
11,256
Country
Germany
Cout/etc. from iostream support just serial streaming of data.
You can stream text to the screen in a very rudimentary way with it, but it is most like streaming text to a file, etc.
It is not meant to address the screen space randomly or so.

I am not sure if this is available in 3DS, but try using ncurses instead.
 
D

Deleted User

Guest
OP
Cout/etc. from iostream support just serial streaming of data.
You can stream text to the screen in a very rudimentary way with it, but it is most like streaming text to a file, etc.
It is not meant to address the screen space randomly or so.

I am not sure if this is available in 3DS, but try using ncurses instead.

Okay I will give it a try thanks
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • K3Nv2 @ K3Nv2:
    Jaws is on a diet
  • K3Nv2 @ K3Nv2:
    Damn power went out
  • BigOnYa @ BigOnYa:
    Ok xdqwerty, your little bro prob tripped On the cord and unplugged you
  • K3Nv2 @ K3Nv2:
    Ya I'm afraid of the dark hug me
  • BigOnYa @ BigOnYa:
    Grab and hold close your AncientBoi doll.
  • K3Nv2 @ K3Nv2:
    Damn didn't charge my external battery either
  • BigOnYa @ BigOnYa:
    Take the batteries out of your SuperStabber3000... Or is it gas powered?
  • K3Nv2 @ K3Nv2:
    I stole batteries from your black mamba
    +1
  • K3Nv2 @ K3Nv2:
    My frozen food better hold up for an hour I know that
  • BigOnYa @ BigOnYa:
    Or else gonna be a big lunch and dinner tomorrow.
  • BigOnYa @ BigOnYa:
    Did you pay your power bill? Or give all yo money to my wife, again.
  • K3Nv2 @ K3Nv2:
    Oh good the estimated time is the same exact time they just said
    +1
  • BigOnYa @ BigOnYa:
    Load up your pc and monitor, and head to a McDonalds dining room, they have free WiFi
  • K3Nv2 @ K3Nv2:
    Sir please watch your porn in the bathroom
    +2
  • BigOnYa @ BigOnYa:
    No sir we can not sell you anymore apple pies, after what you did with the last one.
  • K3Nv2 @ K3Nv2:
    We ran out
  • HiradeGirl @ HiradeGirl:
    for your life
    +1
  • K3Nv2 @ K3Nv2:
    My life has no value my fat ass is staying right here
  • K3Nv2 @ K3Nv2:
    Nearly 4 hours without power :(
  • Veho @ Veho:
    SO POWERLESS
  • K3Nv2 @ K3Nv2:
    Tell Kanye I need power
  • DinohScene @ DinohScene:
    Better start running in your hamster wheel
    DinohScene @ DinohScene: Better start running in your hamster wheel