filfat

3DS_UI Example 1 v0.1

Mar 15th, 2015
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. //Required classes for 3DS_UI
  2. #include <3ds.h>
  3. #include <iostream>
  4. #include <vector>
  5. #include <3DS_UI.h>
  6.  
  7. int main() {
  8.     //Initialize services
  9.     srvInit();
  10.     aptInit();
  11.     hidInit(NULL);
  12.     gfxInitDefault();
  13.     gfxSet3D(true);
  14.  
  15.     //Init 3DS_UI
  16.     uiInit();
  17.    
  18.     //Creates two windows, one for the upper screen and one for the bottom screen
  19.     uiWindow windowTop =  createWindow();
  20.     uiWindow windowBottom =  createWindow();
  21.     setWindowMode(true, true, windowTop);
  22.     setWindowMode(false, false, windowBottom);
  23.  
  24.     //Creates a new TextBlock
  25.     uiTextBlock* textBlock = new uiTextBlock("TextBlock1");
  26.     textBlock->configure(0, 0, robootoBlack, "Hello World!");
  27.  
  28.     //Adds the element(s) to the window(s)
  29.     addElement(windowTop, textBlock);
  30.  
  31.     //Sets the upper window's header
  32.     windowTop.navbar.header = "Example 1";
  33.  
  34.     while (aptMainLoop())
  35.     {
  36.         //Return to the launcher if we press 'A'
  37.         hidScanInput();
  38.         u32 kDown = hidKeysDown();
  39.         if (kDown & KEY_A)
  40.             break;
  41.  
  42.         //Renders both windows
  43.         renderWindow(windowTop);
  44.         renderWindow(windowBottom);
  45.     }
  46.  
  47.     //Removes the element
  48.     removeElement(windowTop, "TextBlock1");
  49.  
  50.     //Frees up the memory used by the windows
  51.     deleteWindow(windowTop);
  52.     deleteWindow(windowBottom);
  53.  
  54.     //Exit UI
  55.     uiExit();
  56.  
  57.     //Deinitialize services
  58.     gfxExit();
  59.     hidExit();
  60.     aptExit();
  61.     srvExit();
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment