From: binarymaster Date: Sat, 30 Sep 2017 11:56:51 +0000 (+0300) Subject: Preview: Make checkerboard optional X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=797ba76501e5360f4d02d6aade613dc529a24213;p=d2df-editor.git Preview: Make checkerboard optional --- diff --git a/src/editor/f_addresource_texture.lfm b/src/editor/f_addresource_texture.lfm index 2c4fa54..bc6af2d 100644 --- a/src/editor/f_addresource_texture.lfm +++ b/src/editor/f_addresource_texture.lfm @@ -39,9 +39,9 @@ inherited AddTextureForm: TAddTextureForm ClientWidth = 258 TabOrder = 6 object iPreview: TImage - Left = 0 + Left = 1 Height = 256 - Top = 0 + Top = 1 Width = 256 end end diff --git a/src/editor/f_addresource_texture.pas b/src/editor/f_addresource_texture.pas index 0ab28a5..86566cf 100644 --- a/src/editor/f_addresource_texture.pas +++ b/src/editor/f_addresource_texture.pas @@ -241,7 +241,7 @@ function CreateBitMap(Data: Pointer; DataSize: Cardinal): TBitMap; var img: TImageData; clr: TColor32Rec; - bgc: Byte; + bgc: TColor32Rec; ii: PByte; Width, Height: Integer; @@ -274,13 +274,22 @@ begin // HACK: Lazarus's TBitMap doesn't seem to have a working 32 bit mode, so // mix color with checkered background. Also, can't really read // CHECKERS.tga from here. FUCK! - if (((x shr 3) and 1) = 0) xor (((y shr 3) and 1) = 0) then - bgc := 255 + if UseCheckerboard then + begin + if (((x shr 3) and 1) = 0) xor (((y shr 3) and 1) = 0) then + bgc.Color := $FDFDFD + else + bgc.Color := $CBCBCB; + end else - bgc := 200; - clr.r := ClampToByte((Byte(255 - clr.a) * bgc + clr.a * clr.r) div 255); - clr.g := ClampToByte((Byte(255 - clr.a) * bgc + clr.a * clr.g) div 255); - clr.b := ClampToByte((Byte(255 - clr.a) * bgc + clr.a * clr.b) div 255); + begin + bgc.r := GetRValue(PreviewColor); + bgc.g := GetGValue(PreviewColor); + bgc.b := GetBValue(PreviewColor); + end; + clr.r := ClampToByte((Byte(255 - clr.a) * bgc.r + clr.a * clr.r) div 255); + clr.g := ClampToByte((Byte(255 - clr.a) * bgc.g + clr.a * clr.g) div 255); + clr.b := ClampToByte((Byte(255 - clr.a) * bgc.b + clr.a * clr.b) div 255); // TODO: check for RGB/BGR somehow? ii^ := clr.b; Inc(ii); ii^ := clr.g; Inc(ii); diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index c5821c4..070939d 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -295,6 +295,7 @@ var DrawPanelSize: Boolean; BackColor: TColor; PreviewColor: TColor; + UseCheckerboard: Boolean; Scale: Byte; RecentCount: Integer; RecentFiles: TStringList; @@ -2655,6 +2656,7 @@ begin DrawPanelSize := config.ReadBool('Editor', 'DrawPanelSize', True); BackColor := config.ReadInt('Editor', 'BackColor', $7F6040); PreviewColor := config.ReadInt('Editor', 'PreviewColor', $00FF00); + UseCheckerboard := config.ReadBool('Editor', 'UseCheckerboard', True); gColorEdge := config.ReadInt('Editor', 'EdgeColor', COLOR_EDGE); gAlphaEdge := config.ReadInt('Editor', 'EdgeAlpha', ALPHA_EDGE); if gAlphaEdge = 255 then @@ -2798,8 +2800,14 @@ begin if not g_GetTexture(SelectedTexture(), ID) then g_GetTexture('NOTEXTURE', ID); g_GetTextureSizeByID(ID, Width, Height); - if g_GetTexture('PREVIEW', PID) then - e_DrawFill(PID, RenderPanel.Width-Width, RenderPanel.Height-Height, Width div 16 + 1, Height div 16 + 1, 0, True, False); + if UseCheckerboard then + begin + if g_GetTexture('PREVIEW', PID) then + e_DrawFill(PID, RenderPanel.Width-Width, RenderPanel.Height-Height, Width div 16 + 1, Height div 16 + 1, 0, True, False); + end else + e_DrawFillQuad(RenderPanel.Width-Width-2, RenderPanel.Height-Height-2, + RenderPanel.Width-1, RenderPanel.Height-1, + GetRValue(PreviewColor), GetGValue(PreviewColor), GetBValue(PreviewColor), 0); e_Draw(ID, RenderPanel.Width-Width, RenderPanel.Height-Height, 0, True, False); end; diff --git a/src/editor/f_options.lfm b/src/editor/f_options.lfm index 97ef8e2..b100ee3 100644 --- a/src/editor/f_options.lfm +++ b/src/editor/f_options.lfm @@ -79,7 +79,7 @@ object OptionsForm: TOptionsForm object LabelMinimap: TLabel Left = 190 Height = 13 - Top = 131 + Top = 129 Width = 112 Caption = 'Масштаб мини-карты:' ParentColor = False @@ -163,12 +163,12 @@ object OptionsForm: TOptionsForm Width = 11 Caption = '..' OnClick = bPreviewClick - TabOrder = 12 + TabOrder = 13 end object cbScale: TComboBox Left = 344 Height = 21 - Top = 131 + Top = 129 Width = 70 ItemHeight = 13 ItemIndex = 0 @@ -177,7 +177,7 @@ object OptionsForm: TOptionsForm '2x' ) Style = csDropDownList - TabOrder = 13 + TabOrder = 14 Text = '1x' end object cbShowTexture: TCheckBox @@ -199,21 +199,21 @@ object OptionsForm: TOptionsForm object eRecent: TEdit Left = 344 Height = 21 - Top = 184 + Top = 180 Width = 57 - TabOrder = 14 + TabOrder = 15 Text = '5' end object UpDown3: TUpDown Left = 401 Height = 21 - Top = 184 + Top = 180 Width = 12 Associate = eRecent Max = 10 Min = 2 Position = 5 - TabOrder = 15 + TabOrder = 16 Wrap = False end object eDotStepTwo: TEdit @@ -268,6 +268,16 @@ object OptionsForm: TOptionsForm TabOrder = 7 Text = '1' end + object cbCheckerboard: TCheckBox + Left = 190 + Height = 17 + Top = 94 + Width = 145 + Caption = 'Использовать шахматку' + Checked = True + State = cbChecked + TabOrder = 12 + end end object bOK: TButton Left = 262 diff --git a/src/editor/f_options.pas b/src/editor/f_options.pas index 926479e..1f297ec 100644 --- a/src/editor/f_options.pas +++ b/src/editor/f_options.pas @@ -13,6 +13,7 @@ type TOptionsForm = class (TForm) bOK: TButton; bCancel: TButton; + cbCheckerboard: TCheckBox; ColorDialog: TColorDialog; GroupBox1: TGroupBox; // Общие настройки: @@ -115,6 +116,7 @@ begin eDotStepTwo.Text := IntToStr(DotStepTwo); sBackColor.Brush.Color := BackColor; sPreviewColor.Brush.Color := PreviewColor; + cbCheckerboard.Checked := UseCheckerboard; if Scale = 2 then cbScale.ItemIndex := 1 else @@ -184,6 +186,7 @@ begin DrawPanelSize := cbShowSize.Checked; BackColor := sBackColor.Brush.Color; PreviewColor := sPreviewColor.Brush.Color; + UseCheckerboard := cbCheckerboard.Checked; if cbScale.ItemIndex = 1 then Scale := 2 @@ -207,6 +210,7 @@ begin config.WriteBool('Editor', 'DrawPanelSize', DrawPanelSize); config.WriteInt('Editor', 'BackColor', BackColor); config.WriteInt('Editor', 'PreviewColor', PreviewColor); + config.WriteBool('Editor', 'UseCheckerboard', UseCheckerboard); config.WriteInt('Editor', 'Scale', cbScale.ItemIndex); config.WriteInt('Editor', 'RecentCount', re); config.WriteStr('Editor', 'Language', gLanguage); diff --git a/src/editor/g_language.pas b/src/editor/g_language.pas index 7bb6fb3..af9b436 100644 --- a/src/editor/g_language.pas +++ b/src/editor/g_language.pas @@ -483,6 +483,7 @@ Type I_CTRL_ES_GRID, I_CTRL_ES_TEXTURE, I_CTRL_ES_PANEL_SIZE, + I_CTRL_ES_CHECKERBOARD, I_CTRL_PACK_TEXTURES, I_CTRL_PACK_SKY, @@ -1558,6 +1559,8 @@ Const 'Показывать текстуру панели'), ('CTRL ES PANEL SIZE', 'Show Panel Size', 'Показывать размеры панели '), + ('CTRL ES CHECKERBOARD', 'Use Checkerboard', + 'Использовать шахматку'), ('CTRL PACK TEXTURES', 'Textures', 'Текстуры'), @@ -2303,6 +2306,7 @@ begin cbShowDots.Caption := _lc[I_CTRL_ES_GRID]; cbShowTexture.Caption := _lc[I_CTRL_ES_TEXTURE]; cbShowSize.Caption := _lc[I_CTRL_ES_PANEL_SIZE]; + cbCheckerboard.Caption := _lc[I_CTRL_ES_CHECKERBOARD]; LabelGrid.Caption := _lc[I_LAB_ES_GRID]; LabelGridCol.Caption := _lc[I_LAB_ES_GRID_COLOR]; LabelBack.Caption := _lc[I_LAB_ES_BACK];