*/}}
Browse Source

Save/theme/translation updates

YimingWu 3 weeks ago
parent
commit
9e28cc58c4
8 changed files with 52 additions and 10 deletions
  1. 7 0
      la_data.c
  2. 5 0
      la_data.h
  3. 6 1
      la_interface.h
  4. 10 6
      la_kernel.c
  5. 4 2
      la_resource.c
  6. 6 0
      resources/la_properties.c
  7. 1 0
      resources/la_templates.c
  8. 13 1
      resources/la_translations.c

+ 7 - 0
la_data.c

@@ -3952,11 +3952,13 @@ void laClearManagedUDF(){
 
 void laSaveManagedUDF(){
     laRegisterModifications(0,0,0,1);
+    if(MAIN.PreSave){ MAIN.PreSave(); }
     for(laManagedUDF* m=MAIN.ManagedUDFs.pFirst;m;m=m->Item.pNext){
         if(!m->udf) continue;
         if(m->udf->PropsToOperate.pFirst){ laPackUDF(m->udf, 1, 1); }
         laCloseUDF(m->udf);// just in case
     }
+    if(MAIN.PostSave){ MAIN.PostSave(); }
 }
 
 void laPropagateUDF(laPropContainer* pc, void* inst, int force){
@@ -3965,6 +3967,11 @@ void laPropagateUDF(laPropContainer* pc, void* inst, int force){
     pc->UDFPropagate(inst, udf, force);
 }
 
+void laSetSaveCallback(laPreSaveF PreSave, laPostSaveF PostSave){
+    MAIN.PreSave=PreSave;
+    MAIN.PostSave=PostSave;
+}
+
 //==========================================================================[Manifest]
 
 void laAddResourceFolder(char* Path){

+ 5 - 0
la_data.h

@@ -91,6 +91,9 @@ typedef void (*laContainerResetF)(void *);
 typedef void (*laContainerUndoTouchedF)(void *, u64bit hint);
 typedef void (*laContainerpUDFPropagateF)(void *, void* udf, int Force);
 
+typedef void (*laPreSaveF)();
+typedef void (*laPostSaveF)();
+
 typedef int (*laActionHolderVerifyF)(void* Holder, laPropContainer* HolderType, void* inst, laPropContainer* InstType);
 
 #define LA_PROP_GENERAL_ROOT (1<<7)
@@ -1010,6 +1013,8 @@ void laSaveManagedUDF();
 
 void laPropagateUDF(laPropContainer* pc, void* inst, int force);
 
+void laSetSaveCallback(laPreSaveF PreSave, laPostSaveF PostSave);
+
 //================== manifest
 
 void laAddResourceFolder(char* Path);

+ 6 - 1
la_interface.h

@@ -519,6 +519,8 @@ STRUCTURE(LA){
     laHash65536* DBInstLink;
 
     laDiffPushEverythingF PushEverything;
+    laPreSaveF PreSave;
+    laPostSaveF PostSave;
 
     laAnimation* Animation;
 
@@ -823,7 +825,7 @@ extern laProp* LA_PROP_CONTROLLER;
 #define LA_UI_NORMAL  0
 #define LA_UI_ACTIVE  (1<<0)
 #define LA_UI_EDITING  (1<<1)
-#define LA_UI_DISABLED (1<<8)
+#define LA_UI_DISABLED (1<<30)
 
 #define LA_BT_NORMAL LA_UI_NORMAL
 #define LA_BT_ACTIVE LA_UI_ACTIVE
@@ -839,6 +841,8 @@ extern laProp* LA_PROP_CONTROLLER;
 #define LA_BT_SVERTEX (LA_BT_VERTEX|LA_BT_SELECTED)
 #define LA_BT_SEDGE   (LA_BT_EDGE|LA_BT_SELECTED)
 #define LA_BT_SFACE   (LA_BT_FACE|LA_BT_SELECTED)
+#define LA_BT_WARNING (1<<12)
+#define LA_UI_WARNING LA_BT_WARNING
 
 #define LA_UI_TAG_IS_OFFSCREEN  (1<<0)
 #define LA_UI_TAG_CAVANS_SCALED (1<<1)
@@ -856,6 +860,7 @@ STRUCTURE(laTheme){
     real ColorBkg[4];
     real Color[4];
     real AccentColor[4];
+    real WarningColor[4];
     real SelectionColor[4];
     real CursorColor[4];
     real InactiveMix;

+ 10 - 6
la_kernel.c

@@ -1820,6 +1820,7 @@ real* laAccentColor(int which){
     switch(which){
         default:
         case LA_BT_NORMAL: case LA_UI_EDITING: case LA_BT_ACTIVE: return MAIN.CurrentTheme->SelectionColor;
+        case LA_BT_WARNING: return MAIN.CurrentTheme->WarningColor;
         case LA_BT_BORDER: case LA_BT_TEXT: case LA_BT_TEXT_ACTIVE: return MAIN.CurrentTheme->CursorColor;
         case LA_BT_VERTEX: return MAIN.CurrentTheme->VertexColor;
         case LA_BT_FACE:
@@ -1846,7 +1847,7 @@ void la_RefreshBoxedThemeColor(laBoxedTheme* bt){
 }
 void la_RefreshThemeColorSelf(laTheme* th){
     tnsVectorCopy3d(th->AccentColor, th->CursorColor);   th->CursorColor[3]=th->CursorAlpha;
-    tnsVectorCopy3d(th->AccentColor, th->SelectionColor);th->SelectionColor[3]=th->SelectionAlpha;
+    tnsVectorCopy3d(th->AccentColor, th->SelectionColor);th->SelectionColor[3]=th->SelectionAlpha; th->WarningColor[3]=th->SelectionAlpha;
     real hcy[3], usehcy[3];
     tnsRGB2HCY(th->Color,hcy); tnsVectorCopy3d(hcy,usehcy);
     usehcy[2]=th->VertexBrightness; tnsHCY2RGB(usehcy, th->VertexColor); th->VertexColor[3]=th->VertexTransparency;
@@ -6137,12 +6138,15 @@ int la_DrawUiListRecursive(laUiListDraw *uild, laUiList *uil, int L, int R, int
 
                     if ((!la_UiListInBoundEx(sub, uild)) && (!RegisterNodes)) continue;
 
-                    if(!(ui->Flags&LA_UI_COLLECTION_NO_HIGHLIGHT) && NeedDraw){
-                        if (CanGetState){
+                    if(NeedDraw){ int drawn=0;
+                        if (!(ui->Flags&LA_UI_COLLECTION_NO_HIGHLIGHT) && sub->Instance == Active){
+                            la_DrawInstanceBkg(sub, laAccentColor(LA_BT_NORMAL),bt->LP,bt->RP); drawn=1;
+                        }
+                        if (CanGetState && !drawn){
                             State = laGetUiState(ui->PP.LastPs->p, sub->Instance);
-                            la_DrawInstanceBkg(sub, laAccentColor(LA_BT_NORMAL),bt->LP,bt->RP);
-                        }elif (sub->Instance == Active){
-                            la_DrawInstanceBkg(sub, laAccentColor(LA_BT_NORMAL),bt->LP,bt->RP);
+                            if(State >= 0){
+                                la_DrawInstanceBkg(sub, laAccentColor(State),bt->LP,bt->RP);
+                            }
                         }
                     }
 

+ 4 - 2
la_resource.c

@@ -144,8 +144,9 @@ void la_RegisterMainThemes(){
     t = laDesignTheme("Classic Light", "YimingWu");{
         LA_SET3(t->Color, 0.58,0.58,0.55);
         LA_SET3(t->AccentColor, 0.27,0.47,0.79);
+        LA_SET3(t->WarningColor, 0.9,0.45,0.2);
         t->InactiveMix=0.7; t->InactiveSaturation=0.2;
-        t->CursorAlpha=0.9; t->SelectionAlpha=0.3;
+        t->CursorAlpha=0.9; t->SelectionAlpha=0.5;
         t->WireBrightness=0.5; t->WireSaturation=0.6; t->WireTransparency=0.65;
         t->EdgeBrightness=0.65; t->EdgeTransparency=0.8; t->VertexBrightness=0.65, t->VertexTransparency=0.9;
         t->SelectedFaceTransparency=0.6,t->SelectedEdgeTransparency=0.9, t->SelectedVertexTransparency=1.0;
@@ -186,8 +187,9 @@ void la_RegisterMainThemes(){
     t = laDesignTheme("Classic Dark", "YimingWu");{
         LA_SET3(t->Color, 0.5,0.4,0.3);
         LA_SET3(t->AccentColor, 0.17,0.74,0.49);
+        LA_SET3(t->WarningColor, 0.9,0.45,0.2);
         t->InactiveMix=0.7; t->InactiveSaturation=0.2;
-        t->CursorAlpha=0.9; t->SelectionAlpha=0.3;
+        t->CursorAlpha=0.9; t->SelectionAlpha=0.4;
         t->WireBrightness=0.6; t->WireSaturation=0.7; t->WireTransparency=0.65;
         t->EdgeBrightness=0.05; t->EdgeTransparency=0.8; t->VertexBrightness=0.05, t->VertexTransparency=0.9;
         t->SelectedFaceTransparency=0.6,t->SelectedEdgeTransparency=0.9, t->SelectedVertexTransparency=1.0;

+ 6 - 0
resources/la_properties.c

@@ -53,6 +53,11 @@ void laset_ThemeAccentColor(laTheme* t, real* array){
     la_RefreshThemeColor(t);
     laRedrawAllWindows();
 }
+void laset_ThemeWarningColor(laTheme* t, real* array){
+    tnsVectorCopy4d(array,t->WarningColor);
+    la_RefreshThemeColor(t);
+    laRedrawAllWindows();
+}
 void laset_ThemeInactiveSaturation(laTheme* t, real a){
     t->InactiveSaturation=a;
     la_RefreshThemeColor(t);
@@ -1494,6 +1499,7 @@ void la_RegisterInternalProps(){
                 laAddSubGroup(p, "boxed_themes", "Boxed Themes", "The Boxed Theme For Single UiItem Or Panel", "boxed_theme",0,0,0,-1, 0,0,0,0,0,0,offsetof(laTheme, BoxedThemes), 0);
                 laAddFloatProperty(p, "color", "Color", "Base color of the theme", LA_WIDGET_FLOAT_COLOR, "R,G,B,A", 0,1, 0,0.025, 1, 0,offsetof(laTheme, Color), 0,0,4, 0,0,0,0,laset_ThemeColor, 0,0,0);
                 laAddFloatProperty(p, "accent_color", "Accent Color", "Theme accent color for hightlight etc", LA_WIDGET_FLOAT_COLOR, "R,G,B,A", 0,1, 0,0.025, 1, 0,offsetof(laTheme, AccentColor), 0,0,4, 0,0,0,0,laset_ThemeAccentColor, 0,0,0);
+                laAddFloatProperty(p, "warning_color", "Warning Color", "Theme accent color for warning etc", LA_WIDGET_FLOAT_COLOR, "R,G,B,A", 0,1, 0,0.025, 1, 0,offsetof(laTheme, WarningColor), 0,0,4, 0,0,0,0,laset_ThemeWarningColor, 0,0,0);
                 laAddFloatProperty(p, "inactive_saturation", "Inactive Saturation", "Reduced saturation on inactive widgets", 0,0,0,1, 0,0.025, 1, 0,offsetof(laTheme, InactiveSaturation), 0,0,1, 0,0,0,0,laset_ThemeInactiveSaturation, 0,0,0);
                 laAddFloatProperty(p, "inactive_mix", "Inactive Mix", "Reduced alpha on inactive widgets", 0,0,0,1, 0,0.025, 1, 0,offsetof(laTheme, InactiveMix), 0,0,1, 0,0,0,0,laset_ThemeInactiveMix, 0,0,0);
                 laAddFloatProperty(p, "cursor_alpha", "Cursor Alpha", "Transparency of the cursor", 0,0,0,1, 0,0.025, 1, 0,offsetof(laTheme, CursorAlpha), 0,0,1, 0,0,0,0,laset_ThemeCursorAlpha, 0,0,0);

+ 1 - 0
resources/la_templates.c

@@ -665,6 +665,7 @@ void laui_Theme(laUiList *uil, laPropPack *Base, laPropPack *UNUSED_This, laColu
     laShowLabel(uil, col, "Basics:",0,0);
     laShowLabel(uil, cl, "Base Color:",0,0)->Flags|=LA_TEXT_ALIGN_RIGHT; laShowItem(uil, cr, Base, "color");
     laShowLabel(uil, cl, "Accent Color:",0,0)->Flags|=LA_TEXT_ALIGN_RIGHT; laShowItem(uil, cr, Base, "accent_color");
+    laShowLabel(uil, cl, "Warning Color:",0,0)->Flags|=LA_TEXT_ALIGN_RIGHT; laShowItem(uil, cr, Base, "warning_color");
     laShowItem(uil, cr, Base, "cursor_alpha");
     laShowItem(uil, cr, Base, "selection_alpha");
     laShowItem(uil, cr, Base, "inactive_mix");

+ 13 - 1
resources/la_translations.c

@@ -19,6 +19,18 @@
 #include "la_5.h"
 
 static const char *entries[]={
+"Auto Switch","自动切换",
+"Per screen config","针对每个屏幕设置:",
+"Will remove input mapping","将删除映射",
+"Will remove this key map entry","将删除该映射条目",
+"Select Signal","选择信号",
+"Press a key:","按任意键:",
+"Select Key","选择按键",
+"Joystick","手柄",
+"Keyboard","键盘",
+"New Entry","新条目",
+"New Mapping","新建映射",
+"Warning Color:","警告颜色:",
 "Viewport:","视口:",
 "Halftone Factor","半调色程度",
 "Halftone Size","半调色尺寸",
@@ -165,7 +177,7 @@ static const char *entries[]={
 "Controllers","控制器",
 "Data Manager","数据管理",
 "System","系统",
-"Input Mapper","输入映射",
+"Input Mapping","输入映射",
 "Terminal","终端",
 "Controlling","控制",
 "Tools","工具",