]> Chaos Git - vn/vndc.git/commitdiff
As it turns out, setimg is actually based on NDS adapted coordinates by this formula...
authorchaoskagami <chaos.kagami@gmail.com>
Mon, 25 Aug 2014 05:28:01 +0000 (01:28 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Mon, 25 Aug 2014 05:28:01 +0000 (01:28 -0400)
external/include/zero/TextManager.hpp
external/include/zero/UDisplayable.hpp
external/src/zero/TextManager.cpp
external/src/zero/UDisplayable.cpp
vndc/src/Loop.cpp
vndc/src/op_setimg.cpp

index 7e97530950f0f5b7378b826bab1a1a99f235b7b7..574b20e61061d5b520b4910bb93ac3207989639f 100644 (file)
@@ -6,7 +6,7 @@ class TextManager {
                ~TextManager();
 
                // Base font functions.
-               int LoadFont(char* fname);
+               int LoadFont(char* fname, int size);
                void Render(char* text);
                void Render(char* text, int x, int y);
 
@@ -15,7 +15,7 @@ class TextManager {
 
                // Property functions.
                // void SetStyle(int style);
-               // void SetFontUsed(int font);
+               void SetFontUsed(int font);
                void SetColor(int r, int g, int b, int a);
 
                // Complex functions.
index 076bdd8dd6bda49c8bf7f35a731cc50e612c11b5..eb8f004a65c92c2e88462ee2e1af97ede5c3554d 100644 (file)
@@ -28,6 +28,9 @@ typedef enum {
                        int GetXI();
                        int GetYI();
 
+                       int GetW();
+                       int GetH();
+
                        void Blit();
 
                        int* GetHitbox();
index 4109597d1ec0b9f0cde0895f8c7b5532b2e34c90..d741dd40bbb80507ce2e5e7a897a9b329dd9d459 100644 (file)
@@ -8,7 +8,7 @@ TextManager::TextManager(ContextManager* ct) {
                exit(-8);
        }
 
-       LoadFont((char*)"default.ttf");
+       LoadFont((char*)"default.ttf", 20);
 
        color.r = 255;
        color.g = 255;
@@ -28,13 +28,13 @@ TextManager::~TextManager() {
        TTF_Quit();
 }
 
-int TextManager::LoadFont(char* fname) {
+int TextManager::LoadFont(char* fname, int size) {
 
        ++fonts_loaded;
 
        fonts = (TTF_Font**)realloc(fonts, sizeof(TTF_Font*) * fonts_loaded);
 
-       if ( !(fonts[fonts_loaded - 1] = TTF_OpenFont(fname, 20) ) ) {
+       if ( !(fonts[fonts_loaded - 1] = TTF_OpenFont(fname, size) ) ) {
                printf("Font Open Failed. Load attempt: %s. Msg: %s\n", fname, TTF_GetError());
        }
 
@@ -128,3 +128,8 @@ void TextManager::SetColor(int r, int g, int b, int a)
        color.b = b;
        color.a = a;
 }
+
+void TextManager::SetFontUsed(int index)
+{
+       current_font = index;
+}
index c85c925aec84f665bbbbaffeb6bc3c5839a74e4f..80742b7e5615e47a1e996675e2a4dd53d663972d 100644 (file)
                return this->loc.y;
        }
 
+       // Get Width
+
+       int UDisplayable::GetW() {
+               if (Error)
+                       return 0;
+               return this->bmp_w;
+       }
+
+       // Get Height
+
+       int UDisplayable::GetH() {
+               if (Error)
+                       return 0;
+               return this->bmp_h;
+       }
+
        // Blit to an associated context.
 
        void UDisplayable::Blit() {
index aa7c8a672b3d0ee42f3757e9d6365d235acf80c7..fa7107c4fda9f9832be7399c1abd0c8372a0227a 100644 (file)
@@ -55,7 +55,11 @@ void Setup() {
        GetData()->s_flags = new std::map<std::string, int>();
        GetData()->g_flags = new std::map<std::string, int>();
 
-       GetData()->ctx->Text()->Outline(2);
+       // Font
+       GetData()->ctx->Text()->LoadFont((char*)"default.ttf", 24);
+       GetData()->ctx->Text()->SetFontUsed(1);
+
+       GetData()->ctx->Text()->Outline(1);
        GetData()->ctx->Text()->SetColor(255,255,255,255);
 
        op_cleartext();
index 88f708df2b34ec82d11be2ffb79c00f58de7bd84..d1e66ebf5c65b2525e501bebfb257d45f9cbc2f2 100644 (file)
@@ -4,7 +4,7 @@
 
 /*
  * Implements setimg vnds function.
- * bgload file x y
+ * setimg file x y
  */
 
 void op_setimg(char* file, int* x, int* y) {
@@ -21,7 +21,13 @@ void op_setimg(char* file, int* x, int* y) {
        // Load displayable.
        UDisplayable* fg_add = new UDisplayable(GetData()->ctx, Normal, path);
 
-       fg_add->SetXY(*x, *y);
+       // Centered NDS adapted
+       double adp_x = ((double)x[0]) * (GetData()->screen_w / 256);
+       double adp_y = ((double)y[0]) * (GetData()->screen_h / 192);
+       fg_add->SetXY((int)adp_x, (int)adp_y);
+
+       // Raw
+       // fg_add->SetXY(x[0], y[0]);
 
        fg_add->Blit();