fixers
authorhgn <hgodden00@gmail.com>
Sat, 8 Nov 2025 16:40:20 +0000 (16:40 +0000)
committerhgn <hgodden00@gmail.com>
Sat, 8 Nov 2025 16:40:20 +0000 (16:40 +0000)
source/engine/model_entity.h
source/graphics/graphics_software.c
source/graphics/ui.c
source/graphics/vg_graphics.h

index e2c07cdfa8f1e939baccdca177cf359fac0dcc04..be0c9c04dbd935a1edcc482f78490dc4f6f97a9f 100644 (file)
@@ -40,12 +40,13 @@ enum entity_alias
    k_editer_property = 34,
    k_editer_item     = 35,
 
-   k_ent_flame       = 200,
+   k_ent_flame       = 200, // FIXME: Move thiese into own file per-game.
    k_ent_waterfall   = 201,
    k_ent_rb2         = 202,
    k_ent_heatpipe    = 203,
    k_ent_waterlevel  = 204,
    k_ent_viewstone   = 205,
+   k_ent_gauge       = 206,
    k_ent_max
 };
 
@@ -83,7 +84,8 @@ static const char *_entity_alias_str[] =
    [k_ent_script] = "ent_script",
    [k_ent_atom] = "ent_atom",
    [k_ent_cutscene] = "ent_cutscene",
-   [k_ent_light] = "ent_light"
+   [k_ent_light] = "ent_light",
+   [k_ent_max] = NULL
 };
 
 static inline u32 mdl_entity_id_type( u32 entity_id )
index 87c913e6110351f3bc2db98ab3c2c9bfb0f85b5f..1dd8d71e7e4d753f0626467ea36089aa5bc0666f 100644 (file)
@@ -16,6 +16,10 @@ void _graphics_viewport( i16 x, i16 y, i16 w, i16 h )
    _graphics.viewport[2] = w;
    _graphics.viewport[3] = h;
 }
+void _graphics_get_viewport_rect( i16 rect[4] )
+{
+   rect_copy( _graphics.viewport, rect );
+}
 
 void _graphics_push_blendmode( enum blending_mode mode )
 {
index c196f4fe10ca28e791631884cbf205e07c7c16c3..6ca6b688f107b708d11ce24dcc775ecd4c4ecfe5 100644 (file)
@@ -63,31 +63,21 @@ void _ui_get_mouse_co( i16 out_co[2] )
    out_co[1] = _ui.mouse_co[1];
 }
 
+// FIXME BAD
 void _ui_set_encoding( enum ui_text_encoding encoding )
 {
    _ui.text_encoding = encoding;
 }
+enum ui_text_encoding _ui_get_encoding(void)
+{
+   return _ui.text_encoding;
+}
 
 b8 ui_inside_rect( i16 rect[4], i16 co[2] )
 {
    return (co[0] >= rect[0]) && (co[1] >= rect[1]) && (co[0] < rect[0]+rect[2]) && (co[1] < rect[1]+rect[3]);
 }
 
-struct ui_string_decoder
-{
-   /* source */
-   const c8 *string;
-   enum ui_text_encoding encoding;
-   
-   /* internal */
-   u32 buffer_offset, character_index;
-   u32 utf8_counter;
-   
-   /* read from these */
-   i16 grid_co[2];
-   u32 c;
-};
-
 void ui_string_decode_init( struct ui_string_decoder *decoder, const c8 *string, enum ui_text_encoding encoding )
 {
    zero_buffer( decoder, sizeof(struct ui_string_decoder) );
@@ -148,7 +138,7 @@ u32 text_decoder_line_count( struct ui_string_decoder *decoder )
 {
    struct ui_string_decoder copy = *decoder;
    while( ui_string_decode( &copy ) ){}
-   return copy.grid_co[1];
+   return copy.grid_co[1]+1;
 }
 
 void _ui_text( i16 rect[4], const c8 *text, enum ui_align align, union colour colour )
@@ -169,21 +159,25 @@ void _ui_text( i16 rect[4], const c8 *text, enum ui_align align, union colour co
 
    if( align & k_ui_align_y_center )
    {
-      text_root[1] += rect[3]/2 - text_decoder_line_count( &decoder )/2;
-      text_root[1] += kerning[2];
+      text_root[1] += (rect[3] - text_decoder_line_count( &decoder )*kerning[1])/2;
+      //text_root[1] += kerning[2]; ????
    }
 
    b8 align_x = (align & (k_ui_align_x_center|k_ui_align_x_right))? 1:0;
-   while( ui_string_decode( &decoder ) )
+
+decode_loop:
    {
       if( align_x && (align & (k_ui_align_x_center|k_ui_align_x_right)) )
       {
          i16 line_width = text_decoder_line_width( &decoder ) * kerning[0];
-         if( align & k_ui_align_x_center ) text_root[0] = rect[0] + (rect[2]/2 - line_width/2);
+         if( align & k_ui_align_x_center ) text_root[0] = rect[0] + (rect[2] - line_width)/2;
          else                              text_root[0] = rect[0] + (rect[2] - line_width);
          align_x = 0;
       }
 
+      if( !ui_string_decode( &decoder ) )
+         return;
+
       if( decoder.c == '\n' )
          align_x = 1;
       else
@@ -194,6 +188,7 @@ void _ui_text( i16 rect[4], const c8 *text, enum ui_align align, union colour co
             _graphics_glyph( char_root, decoder.c, 1, colour );
          }
    }
+   goto decode_loop;
    //rect_copy( temp_area, clipping_area );
 }
 
index 863f1df33676cc1639c0e13e3ae650ec6f6bf7e2..a21b8e4bcde162535014282d41239880329e9870 100644 (file)
@@ -1,3 +1,4 @@
+#pragma once
 /* Basic graphics
  * ------------------------------------------------------------------------------------------------------------------ */
 
@@ -41,6 +42,7 @@ enum blending_mode
 
 void _graphics_set_target( struct graphics_target *target );
 void _graphics_viewport( i16 x, i16 y, i16 w, i16 h );
+void _graphics_get_viewport_rect( i16 rect[4] );
 void _graphics_pixel_unclipped( i16 co[2], union colour colour );
 void _graphics_pixel( i16 co[2], union colour colour );
 void _graphics_push_blendmode( enum blending_mode mode );
@@ -118,6 +120,24 @@ enum ui_text_encoding
    k_ui_text_utf8
 };
 void _ui_set_encoding( enum ui_text_encoding encoding );
+enum ui_text_encoding _ui_get_encoding(void); // FIXME BAD
+struct ui_string_decoder
+{
+   /* source */
+   const c8 *string;
+   enum ui_text_encoding encoding;
+   
+   /* internal */
+   u32 buffer_offset, character_index;
+   u32 utf8_counter;
+   
+   /* read from these */
+   i16 grid_co[2];
+   u32 c;
+};
+u32 text_decoder_line_count( struct ui_string_decoder *decoder );
+void ui_string_decode_init( struct ui_string_decoder *decoder, const c8 *string, enum ui_text_encoding encoding );
+b8 ui_string_decode( struct ui_string_decoder *decoder );
 
 enum ui_align
 {