*/}}
Browse Source

translation and etc

YimingWu 1 year ago
parent
commit
77d52a1329
5 changed files with 119 additions and 3 deletions
  1. 1 1
      CMakeLists.txt
  2. 6 2
      ouroperations.c
  3. 2 0
      ourpaint.c
  4. 1 0
      ourpaint.h
  5. 109 0
      ourtranslations.c

+ 1 - 1
CMakeLists.txt

@@ -14,7 +14,7 @@ include_directories(
 )
 
 file(GLOB_RECURSE OurPaintFiles 
-    ourpaint.c ouroperations.c ournodes.c
+    ourpaint.c ouroperations.c ournodes.c ourtranslations.c
 )
 
 add_executable(OurPaint ${OurPaintFiles})

+ 6 - 2
ouroperations.c

@@ -775,7 +775,7 @@ int our_LayerEnsureImageBuffer(OurLayer* ol, int OnlyCalculate){
     int l=1000,r=-1000,u=-1000,b=1000; int any=0;
     for(int row=0;row<OUR_TILES_PER_ROW;row++){ if(!ol->TexTiles[row]) continue;
         if(row<b) b=row; if(row>u) u=row;
-        for(int col=0;col<OUR_TILES_PER_ROW;col++){ if(!ol->TexTiles[row][col]) continue;
+        for(int col=0;col<OUR_TILES_PER_ROW;col++){ if(!ol->TexTiles[row][col] || !ol->TexTiles[row][col]->Texture) continue;
             if(col<l) l=col; if(col>r) r=col; any++;
         }
     }
@@ -929,6 +929,8 @@ int our_ImageExportPNG(FILE* fp, int WriteToBuffer, void** buf, int* sizeof_buf,
 
     if(WriteToBuffer){ *buf=LayerWrite.data; *sizeof_buf=LayerWrite.NextData; }
 
+    free(temp_row);
+
     return 1;
 }
 void our_EnsureImageBufferOnRead(OurLayer*l, int W, int H, int UseOffsets, int StartX, int StartY){
@@ -1863,7 +1865,7 @@ void ourRegisterEverything(){
     laAddSubGroup(pc,"current_brush","Current Brush","Current brush","our_brush",0,0,0,offsetof(OurPaint,CurrentBrush),ourget_FirstBrush,0,laget_ListNext,ourset_CurrentBrush,0,0,0,LA_UDF_REFER);
     
     pc=laAddPropertyContainer("our_brush","Our Brush","OurPaint brush",0,0,sizeof(OurBrush),0,0,2);
-    laAddStringProperty(pc,"name","Name","Name of the layer",0,0,0,0,1,offsetof(OurBrush,Name),0,0,0,0,LA_AS_IDENTIFIER);
+    laAddStringProperty(pc,"name","Name","Name of the brush",0,0,0,0,1,offsetof(OurBrush,Name),0,0,0,0,LA_AS_IDENTIFIER);
     laAddIntProperty(pc,"__move","Move Slider","Move Slider",LA_WIDGET_HEIGHT_ADJUSTER,0,0,0,0,0,0,0,0,0,ourset_BrushMove,0,0,0,0,0,0,0,0,0);
     laAddIntProperty(pc,"binding","Binding","Keyboard binding for shortcut access of the brush",0,0,0,9,-1,1,0,0,offsetof(OurBrush,Binding),0,0,0,0,0,0,0,0,0,0,0);
     laAddFloatProperty(pc,"size_10","~10","Base size(radius) of the brush (max at 10)",0,0,"px",10,0,1,10,0,offsetof(OurBrush,Size),0,0,0,0,0,0,0,0,0,0,LA_UDF_IGNORE);
@@ -1976,6 +1978,8 @@ void ourRegisterEverything(){
     laSetFrameCallbacks(ourPreFrame,0,0);
     laSetDiffCallback(ourPushEverything);
     laSetCleanupCallback(ourCleanUp);
+
+    ourMakeTranslations();
 }
 
 int ourInit(){

+ 2 - 0
ourpaint.c

@@ -30,6 +30,8 @@ int main(int argc, char *argv[]){
     laRefreshUDFRegistries();
     laEnsureUserPreferences();
 
+    laLoadHyperResources("OURBRUSH");
+
     for(int i=1;i<argc;i++){
         char* file=argv[i]; 
         laManagedUDF* m; laUDF* udf = laOpenUDF(file, 1, 0, &m);

+ 1 - 0
ourpaint.h

@@ -293,4 +293,5 @@ int ourInit();
 void ourRegisterNodes();
 int ourRebuildBrushEval();
 int ourEvalBrush();
+void ourMakeTranslations();
 

+ 109 - 0
ourtranslations.c

@@ -0,0 +1,109 @@
+/*
+* Our Paint: A light weight GPU powered painting program.
+* Copyright (C) 2022 Wu Yiming
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "ourpaint.h"
+
+extern LA MAIN;
+extern tnsMain* T;
+extern OurPaint *Our;
+
+static const char *entries[]={
+"OurPaint 0.1","好得涂 0.1",
+"Brush Nodes","笔刷节点",
+"Our Paint","好得涂",
+"Brushes","笔刷",
+"Layers","图层",
+"Canvas","画布",
+"Unlocked","已解锁",
+"Position:","位置:",
+"Size:","尺寸:",
+"Brush tool not selected","未选择笔刷工具",
+"Lock","锁定",
+"Border Alpha","边框透明度",
+"No","无",
+"OurPaint is made by Wu Yiming.","好得涂 由吴奕茗制作。",
+"A simple yet flexible node-based GPU painting program.","一个简单灵活的节点控制GPU绘画程序。",
+"OurPaint Blog","好得涂博客",
+"Dev log","开发日志",
+"Single canvas implementation.","单画布实现。",
+"8 Bits","8位",
+"Color Profile:","色彩配置:",
+"Import Layer","导入图层",
+"Merge","合并",
+"Cropping","裁剪",
+"Smoothness","平滑度",
+"Lock Radius","锁定半径",
+"Smudge","涂抹",
+"Clean","干净",
+"Layer","图层",
+"Image","图像",
+"Paint","涂画",
+"Multiply","相乘",
+"Visible","可见",
+"Linear sRGB","线性 sRGB",
+"Generic:","通用:",
+"Transparency","透明度",
+"New Brush","新笔刷",
+"Canvas Scale","画布缩放",
+"Others","其他",
+"Bit Depth:","位深度:",
+"OurPaint v0.1","好得涂 v0.1",
+"New Layer","新图层",
+"Color Space:","色彩空间:",
+"OurPaint","好得涂",
+"Dabs Per Size","每半径的笔触点数",
+"Paintable","可绘图",
+"Use Nodes","使用节点",
+"Paint Undo Limit","绘图撤销限制",
+"Show","显示",
+"Background:","背景:",
+"Angle","角度",
+"Brush Circle","笔刷圆圈",
+"Erasing","擦除",
+"R,G,B","红,绿,蓝",
+"Assign all \"Our Tools\" into:","将所有“工具”指定到: ",
+"Min,Max","最小,最大",
+"Developer:","开发者:",
+"Smudge Resample Length","涂抹重采样长度",
+"Mode:","模式:",
+"Display:","显示:",
+"Hardness","硬度",
+"Export Layer","导出图层",
+" Steps","步",
+"Modified","已更改",
+"Export Image","导出图像",
+"Slender","压扁",
+"Show debug tiles","显示调试图像块",
+"Exporting Defaults:","导出时的默认值:",
+"Default as eraser","默认为橡皮擦",
+"Name of the brush","笔刷名字",
+"Combine","合并",
+"Locked","已锁定",
+"Brush Device","笔刷设备",
+"Brush Outputs","笔刷输出",
+"About","关于",
+"Linear Clay","线性 Clay",
+"Brush Settings","笔刷设置",
+0,0};
+
+void ourMakeTranslations(){
+    transSetLanguage("zh-CN");
+    for(int i=0;;i++){if(!entries[i*2])break;
+        transNewEntry(entries[i*2],entries[i*2+1]);
+    }
+}