OpenClonk
C4ToolsDlg::State Class Reference
Inheritance diagram for C4ToolsDlg::State:
[legend]
Collaboration diagram for C4ToolsDlg::State:
[legend]

Public Member Functions

 State (C4ToolsDlg *dlg)
 
void Clear ()
 
void Default ()
 
 State (C4ToolsDlg *toolsDlg)
 
 ~State ()
 
CGImageRef CreatePreviewImage ()
 
void Default ()
 
void Clear ()
 
 State (C4ToolsDlg *toolsDlg)
 
void LoadBitmaps (HINSTANCE instance)
 
 ~State ()
 
void Clear ()
 
void Default ()
 
class C4ToolsDlgGetOwner ()
 

Public Attributes

HWND hDialog
 
C4WindowpPreviewWindow
 
HBITMAP hbmBrush
 
HBITMAP hbmBrush2
 
HBITMAP hbmLine
 
HBITMAP hbmLine2
 
HBITMAP hbmRect
 
HBITMAP hbmRect2
 
HBITMAP hbmFill
 
HBITMAP hbmFill2
 
HBITMAP hbmPicker
 
HBITMAP hbmPicker2
 
HBITMAP hbmDynamic
 
HBITMAP hbmStatic
 
HBITMAP hbmExact
 

Protected Types

typedef class InternalState< class C4ToolsDlgSuper
 

Friends

INT_PTR CALLBACK ToolsDlgProc (HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
 

Detailed Description

Definition at line 656 of file C4Console.cpp.

Member Typedef Documentation

◆ Super

typedef class InternalState< class C4ToolsDlg > C4ConsoleGUI::InternalState< class C4ToolsDlg >::Super
protectedinherited

Definition at line 42 of file C4ConsoleGUI.h.

Constructor & Destructor Documentation

◆ State() [1/3]

C4ToolsDlg::State::State ( C4ToolsDlg dlg)
inline

Definition at line 658 of file C4Console.cpp.

658 : State(C4ToolsDlg* dlg): Super(dlg) {}
State(C4ToolsDlg *dlg)
Definition: C4Console.cpp:658
class InternalState< class C4ToolsDlg > Super
Definition: C4ConsoleGUI.h:42

◆ State() [2/3]

C4ToolsDlg::State::State ( C4ToolsDlg toolsDlg)
inline

Definition at line 53 of file C4ConsoleCocoa.mm.

53 : Super(toolsDlg) {}
class InternalState< class C4ToolsDlg > Super
Definition: C4ConsoleGUI.h:42

◆ ~State() [1/2]

C4ToolsDlg::State::~State ( )
inline

Definition at line 54 of file C4ConsoleCocoa.mm.

55  {
56  [ctrler(&Console).toolsPanel orderOut:nil];
57  }
C4Console Console
Definition: C4Globals.cpp:45

◆ State() [3/3]

C4ToolsDlg::State::State ( C4ToolsDlg toolsDlg)
inline

Definition at line 518 of file C4ConsoleWin32.cpp.

519  hbmBrush(nullptr), hbmBrush2(nullptr),
520  hbmLine(nullptr), hbmLine2(nullptr),
521  hbmRect(nullptr), hbmRect2(nullptr),
522  hbmFill(nullptr), hbmFill2(nullptr),
523  hbmPicker(nullptr), hbmPicker2(nullptr),
524  hbmDynamic(nullptr),
525  hbmStatic(nullptr),
526  hbmExact(nullptr)
527  {
528  pPreviewWindow = nullptr;
529  }
C4Window * pPreviewWindow

◆ ~State() [2/2]

C4ToolsDlg::State::~State ( )
inline

Definition at line 548 of file C4ConsoleWin32.cpp.

References C4Window::Clear().

549  {
550  Clear();
551  }
Here is the call graph for this function:

Member Function Documentation

◆ Clear() [1/3]

void C4ToolsDlg::State::Clear ( )
inline

Definition at line 60 of file C4ConsoleCocoa.mm.

References C4Window::Active, C4ConsoleGUI::CreateConsoleWindow(), C4ConsoleGUI::DeleteConsoleWindow(), and C4ConsoleGUI::Out().

60 {}
Here is the call graph for this function:

◆ Clear() [2/3]

void C4ToolsDlg::State::Clear ( )
inline

Definition at line 553 of file C4ConsoleWin32.cpp.

554  {
555  // Unload bitmaps
556  if (hbmBrush) { DeleteObject(hbmBrush); hbmBrush = nullptr; }
557  if (hbmLine) { DeleteObject(hbmLine); hbmLine = nullptr; }
558  if (hbmRect) { DeleteObject(hbmRect); hbmRect = nullptr; }
559  if (hbmFill) { DeleteObject(hbmFill); hbmFill = nullptr; }
560  if (hbmPicker) { DeleteObject(hbmPicker); hbmPicker = nullptr; }
561  if (hbmBrush2) { DeleteObject(hbmBrush2); hbmBrush2 = nullptr; }
562  if (hbmLine2) { DeleteObject(hbmLine2); hbmLine2 = nullptr; }
563  if (hbmRect2) { DeleteObject(hbmRect2); hbmRect2 = nullptr; }
564  if (hbmFill2) { DeleteObject(hbmFill2); hbmFill2 = nullptr; }
565  if (hbmPicker2) { DeleteObject(hbmPicker2); hbmPicker2 = nullptr; }
566  if (hbmDynamic) { DeleteObject(hbmDynamic); hbmDynamic = nullptr; }
567  if (hbmStatic) { DeleteObject(hbmStatic); hbmStatic = nullptr; }
568  if (hbmExact) { DeleteObject(hbmExact); hbmExact = nullptr; }
569  if (pPreviewWindow)
570  {
571  delete pPreviewWindow;
572  pPreviewWindow = nullptr;
573  }
574  if (hDialog) DestroyWindow(hDialog); hDialog=nullptr;
575  }
C4Window * pPreviewWindow

◆ Clear() [3/3]

void C4ToolsDlg::State::Clear ( )
inline

Definition at line 659 of file C4Console.cpp.

Referenced by PropertyDlgProc().

659 {}
Here is the caller graph for this function:

◆ CreatePreviewImage()

CGImageRef C4ToolsDlg::State::CreatePreviewImage ( )

Definition at line 284 of file C4ConsoleCocoa.mm.

285 {
286  C4Surface * sfcPreview;
287  int32_t iPrvWdt,iPrvHgt;
288 
289  iPrvWdt = [ctrler(&Console).previewView frame].size.width;
290  iPrvHgt = [ctrler(&Console).previewView frame].size.height;
291 
292  if (!(sfcPreview=new C4Surface(iPrvWdt,iPrvHgt,0))) return NULL;
293 
294  // fill bg
295  BYTE bCol = 0;
296  C4Pattern Pattern;
297  // Sky material: sky as pattern only
299  {
300  Pattern.Set(::Landscape.GetSky().Surface, 0);
301  }
302  // Material-Texture
303  else
304  {
306  // Get/Create TexMap entry
308  if (iTex)
309  {
310  // Define texture pattern
311  const C4TexMapEntry *pTex = ::TextureMap.GetEntry(iTex);
312  // Security
313  if (pTex)
314  {
315  // Set drawing pattern
316  Pattern = pTex->GetPattern();
317  }
318  }
319  }
320 
322  sfcPreview,
323  iPrvWdt/2,iPrvHgt/2,
324  GetOwner()->Grade,
325  bCol, Pattern, *::Landscape.GetPal()
326  );
327  //Application.DDraw->AttachPrimaryPalette(sfcPreview);
328 
329  DWORD *pixels = new DWORD[iPrvWdt*iPrvHgt];
330  for (int x = 0; x < iPrvWdt; x++) for (int y = 0; y < iPrvHgt; y++)
331  {
332  pixels[x+y*iPrvWdt] = sfcPreview->GetPixDw(x, y, true);
333  }
334  CGDataProviderDirectCallbacks callbacks = {0, ::GetBytePointer, ::ReleaseBytePointer, ::GetBytesAtPosition, 0};
335  CGDataProviderRef pixelData = CGDataProviderCreateDirect(pixels, iPrvWdt*iPrvHgt*sizeof(DWORD), &callbacks);
336  CGImageRef image = CGImageCreate(iPrvWdt, iPrvHgt, 8, 4*8, iPrvWdt*4, [[NSColorSpace deviceRGBColorSpace] CGColorSpace], kCGBitmapByteOrder32Little, pixelData, NULL, true, kCGRenderingIntentDefault);
337  CGDataProviderRelease(pixelData);
338  delete sfcPreview;
339  return image;
340 }
C4Console Console
Definition: C4Globals.cpp:45
class C4Surface * Surface
Definition: C4Sky.h:52
CStdPalette * GetPal() const
uint8_t BYTE
C4TextureMap TextureMap
Definition: C4Texture.cpp:576
Definition: C4Texture.h:48
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
const C4TexMapEntry * GetEntry(int32_t iIndex) const
Definition: C4Texture.h:85
int32_t GetIndex(const char *szMaterial, const char *szTexture, bool fAddIfNotExist=true, const char *szErrorIfFailed=nullptr)
Definition: C4Texture.cpp:414
int32_t Grade
Definition: C4ToolsDlg.h:54
char Texture[C4M_MaxName+1]
Definition: C4ToolsDlg.h:57
C4Landscape Landscape
char Material[C4M_MaxName+1]
Definition: C4ToolsDlg.h:56
class C4Sky & GetSky()
C4Draw * pDraw
Definition: C4Draw.cpp:42
DWORD GetPixDw(int iX, int iY, bool fApplyModulation)
Definition: C4Surface.cpp:491
int32_t Get(const char *szMaterial)
Definition: C4Material.cpp:365
C4MaterialMap MaterialMap
Definition: C4Material.cpp:974
BYTE Mat2PixColDefault(int32_t mat)
Definition: C4Material.h:235
const C4Pattern & GetPattern() const
Definition: C4Texture.h:64
bool Set(class C4Surface *sfcSource, int iZoom=0)
Definition: C4Draw.cpp:114
#define C4TLS_MatSky
Definition: C4ToolsDlg.h:39
void DrawPatternedCircle(C4Surface *sfcDest, int x, int y, int r, BYTE col, C4Pattern &Pattern, CStdPalette &rPal)
Definition: C4Draw.cpp:675
uint32_t DWORD

◆ Default() [1/3]

void C4ToolsDlg::State::Default ( )
inline

Definition at line 59 of file C4ConsoleCocoa.mm.

59 {}

◆ Default() [2/3]

void C4ToolsDlg::State::Default ( )
inline

Definition at line 577 of file C4ConsoleWin32.cpp.

References C4ConsoleGUI::InternalState< class C4ConsoleGUI >::GetOwner().

578  {
579  GetOwner()->ModeBack = true;
580  }
bool ModeBack
Definition: C4ToolsDlg.h:58
Here is the call graph for this function:

◆ Default() [3/3]

void C4ToolsDlg::State::Default ( )
inline

Definition at line 660 of file C4Console.cpp.

660 {}

◆ GetOwner()

class C4ToolsDlg * C4ConsoleGUI::InternalState< class C4ToolsDlg >::GetOwner ( )
inlineinherited

Definition at line 47 of file C4ConsoleGUI.h.

47 {return owner;}

◆ LoadBitmaps()

void C4ToolsDlg::State::LoadBitmaps ( HINSTANCE  instance)
inline

Definition at line 531 of file C4ConsoleWin32.cpp.

References IDB_BRUSH, IDB_BRUSH2, IDB_DYNAMIC, IDB_EXACT, IDB_FILL, IDB_FILL2, IDB_LINE, IDB_LINE2, IDB_PICKER, IDB_PICKER2, IDB_RECT, IDB_RECT2, and IDB_STATIC.

Referenced by C4ConsoleGUIPreviewWindow::Close().

532  {
533  if (!hbmBrush) hbmBrush=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_BRUSH));
534  if (!hbmLine) hbmLine=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_LINE));
535  if (!hbmRect) hbmRect=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_RECT));
536  if (!hbmFill) hbmFill=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_FILL));
537  if (!hbmPicker) hbmPicker=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_PICKER));
538  if (!hbmBrush2) hbmBrush2=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_BRUSH2));
539  if (!hbmLine2) hbmLine2=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_LINE2));
540  if (!hbmRect2) hbmRect2=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_RECT2));
541  if (!hbmFill2) hbmFill2=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_FILL2));
542  if (!hbmPicker2) hbmPicker2=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_PICKER2));
543  if (!hbmDynamic) hbmDynamic=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_DYNAMIC));
544  if (!hbmStatic) hbmStatic=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_STATIC));
545  if (!hbmExact) hbmExact=(HBITMAP)LoadBitmapW(instance,MAKEINTRESOURCEW(IDB_EXACT));
546  }
#define IDB_PICKER
Definition: resource.h:19
#define IDB_FILL
Definition: resource.h:11
#define IDB_PICKER2
Definition: resource.h:20
#define IDB_RECT2
Definition: resource.h:24
#define IDB_BRUSH
Definition: resource.h:5
#define IDB_LINE
Definition: resource.h:15
#define IDB_FILL2
Definition: resource.h:12
#define IDB_DYNAMIC
Definition: resource.h:9
#define IDB_LINE2
Definition: resource.h:16
#define IDB_STATIC
Definition: resource.h:25
#define IDB_EXACT
Definition: resource.h:10
#define IDB_RECT
Definition: resource.h:23
#define IDB_BRUSH2
Definition: resource.h:6
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ ToolsDlgProc

INT_PTR CALLBACK ToolsDlgProc ( HWND  hDlg,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)
friend

Definition at line 585 of file C4ConsoleWin32.cpp.

586 {
587  int32_t iValue;
588  switch (Msg)
589  {
590  //----------------------------------------------------------------------------------------------
591  case WM_CLOSE:
593  break;
594  //----------------------------------------------------------------------------------------------
595  case WM_DESTROY:
596  StoreWindowPosition(hDlg, "Tools", Config.GetSubkeyPath("Console"), false);
597  break;
598  //----------------------------------------------------------------------------------------------
599  case WM_INITDIALOG:
600  return true;
601  //----------------------------------------------------------------------------------------------
602  case WM_PAINT:
603  PostMessage(hDlg,WM_USER,0,0); // For user paint
604  return false;
605  //----------------------------------------------------------------------------------------------
606  case WM_USER:
608  return true;
609  //----------------------------------------------------------------------------------------------
610  case WM_VSCROLL:
611  switch (LOWORD(wParam))
612  {
613  case SB_THUMBTRACK: case SB_THUMBPOSITION:
614  iValue=HIWORD(wParam);
616  break;
617  case SB_PAGEUP: case SB_PAGEDOWN:
618  case SB_LINEUP: case SB_LINEDOWN:
619  iValue=SendDlgItemMessage(hDlg,IDC_SLIDERGRADE,TBM_GETPOS,0,0);
621  break;
622  }
623  return true;
624  //----------------------------------------------------------------------------------------------
625  case WM_COMMAND:
626  // Evaluate command
627  switch (LOWORD(wParam))
628  {
629  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
630  case IDOK:
631  return true;
632  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
635  return true;
636  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
639  return true;
640  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
641  case IDC_BUTTONMODEEXACT:
643  return true;
644  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
645  case IDC_BUTTONBRUSH:
647  return true;
648  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
649  case IDC_BUTTONLINE:
651  return true;
652  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
653  case IDC_BUTTONRECT:
655  return true;
656  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
657  case IDC_BUTTONFILL:
659  return true;
660  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
661  case IDC_BUTTONPICKER:
663  return true;
664  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
667  switch (HIWORD(wParam))
668  {
669  case CBN_SELCHANGE:
670  {
671  // New material or texture selected. Get selection string
672  wchar_t str[100];
673  WORD idCombo = LOWORD(wParam);
674  int32_t cursel = SendDlgItemMessage(hDlg, idCombo, CB_GETCURSEL, 0, 0);
675  SendDlgItemMessage(hDlg, idCombo, CB_GETLBTEXT, cursel, (LPARAM)str);
676  // Convert to ascii
677  StdStrBuf str_buf(str);
678  const char *astr = str_buf.getData();
679  // Update appropriate setting in drawing tool
680  switch (idCombo)
681  {
682  case IDC_COMBOFGMATERIAL: Console.ToolsDlg.SetMaterial(astr); break;
683  case IDC_COMBOFGTEXTURE: Console.ToolsDlg.SetTexture(astr); break;
686  }
687  }
688  return true;
689  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
690  }
691  }
692  return false;
693  //----------------------------------------------------------------------------------------
694  }
695  return false;
696 }
#define IDC_BUTTONRECT
Definition: resource.h:38
C4Config Config
Definition: C4Config.cpp:833
#define IDC_COMBOBGMATERIAL
Definition: resource.h:62
bool SetGrade(int32_t iGrade)
Definition: C4ToolsDlg.cpp:166
C4Console Console
Definition: C4Globals.cpp:45
const char * GetSubkeyPath(const char *strSubkey)
Definition: C4Config.cpp:713
C4ToolsDlg ToolsDlg
Definition: C4Console.h:88
#define IDC_BUTTONFILL
Definition: resource.h:27
#define IDC_COMBOBGTEXTURE
Definition: resource.h:63
void SetTexture(const char *szTexture)
Definition: C4ToolsDlg.cpp:71
#define IDC_BUTTONPICKER
Definition: resource.h:36
const int32_t C4TLS_Rect
Definition: C4ToolsDlg.h:30
const int32_t C4TLS_Picker
Definition: C4ToolsDlg.h:32
#define IDC_BUTTONMODEEXACT
Definition: resource.h:33
const int32_t C4TLS_GradeMax
Definition: C4ToolsDlg.h:35
void SetBackMaterial(const char *szMaterial)
Definition: C4ToolsDlg.cpp:106
#define IDC_BUTTONLINE
Definition: resource.h:29
bool SetLandscapeMode(LandscapeMode iMode, bool flat_chunk_shapes, bool fThroughControl=false)
Definition: C4ToolsDlg.cpp:181
void NeedPreviewUpdate()
Definition: C4Console.cpp:702
const int32_t C4TLS_Brush
Definition: C4ToolsDlg.h:28
#define IDC_BUTTONBRUSH
Definition: resource.h:26
void SetBackTexture(const char *szTexture)
Definition: C4ToolsDlg.cpp:116
#define IDC_BUTTONMODESTATIC
Definition: resource.h:35
#define IDC_COMBOFGTEXTURE
Definition: resource.h:42
const int32_t C4TLS_Fill
Definition: C4ToolsDlg.h:31
#define IDC_SLIDERGRADE
Definition: resource.h:46
#define IDC_BUTTONMODEDYNAMIC
Definition: resource.h:31
const int32_t C4TLS_Line
Definition: C4ToolsDlg.h:29
#define IDC_COMBOFGMATERIAL
Definition: resource.h:41
bool SetTool(int32_t iTool, bool fTemp)
Definition: C4ToolsDlg.cpp:43
uint16_t WORD
void SetMaterial(const char *szMaterial)
Definition: C4ToolsDlg.cpp:60

Member Data Documentation

◆ hbmBrush

HBITMAP C4ToolsDlg::State::hbmBrush

Definition at line 509 of file C4ConsoleWin32.cpp.

◆ hbmBrush2

HBITMAP C4ToolsDlg::State::hbmBrush2

Definition at line 509 of file C4ConsoleWin32.cpp.

◆ hbmDynamic

HBITMAP C4ToolsDlg::State::hbmDynamic

Definition at line 514 of file C4ConsoleWin32.cpp.

◆ hbmExact

HBITMAP C4ToolsDlg::State::hbmExact

Definition at line 516 of file C4ConsoleWin32.cpp.

◆ hbmFill

HBITMAP C4ToolsDlg::State::hbmFill

Definition at line 512 of file C4ConsoleWin32.cpp.

◆ hbmFill2

HBITMAP C4ToolsDlg::State::hbmFill2

Definition at line 512 of file C4ConsoleWin32.cpp.

◆ hbmLine

HBITMAP C4ToolsDlg::State::hbmLine

Definition at line 510 of file C4ConsoleWin32.cpp.

◆ hbmLine2

HBITMAP C4ToolsDlg::State::hbmLine2

Definition at line 510 of file C4ConsoleWin32.cpp.

◆ hbmPicker

HBITMAP C4ToolsDlg::State::hbmPicker

Definition at line 513 of file C4ConsoleWin32.cpp.

◆ hbmPicker2

HBITMAP C4ToolsDlg::State::hbmPicker2

Definition at line 513 of file C4ConsoleWin32.cpp.

◆ hbmRect

HBITMAP C4ToolsDlg::State::hbmRect

Definition at line 511 of file C4ConsoleWin32.cpp.

◆ hbmRect2

HBITMAP C4ToolsDlg::State::hbmRect2

Definition at line 511 of file C4ConsoleWin32.cpp.

◆ hbmStatic

HBITMAP C4ToolsDlg::State::hbmStatic

Definition at line 515 of file C4ConsoleWin32.cpp.

◆ hDialog

HWND C4ToolsDlg::State::hDialog

Definition at line 506 of file C4ConsoleWin32.cpp.

Referenced by C4ConsoleGUIPreviewWindow::Close(), and PropertyDlgProc().

◆ pPreviewWindow

C4Window* C4ToolsDlg::State::pPreviewWindow

Definition at line 507 of file C4ConsoleWin32.cpp.

Referenced by C4ConsoleGUIPreviewWindow::Close().


The documentation for this class was generated from the following files: