1/*
2 * LegacyClonk
3 *
4 * Copyright (c) 1998-2000, Matthes Bender (RedWolf Design)
5 * Copyright (c) 2017-2022, The LegacyClonk Team and contributors
6 *
7 * Distributed under the terms of the ISC license; see accompanying file
8 * "COPYING" for details.
9 *
10 * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11 * See accompanying file "TRADEMARK" for details.
12 *
13 * To redistribute this file separately, substitute the full license texts
14 * for the above references.
15 */
16
17/* Holds a single text file component from a group */
18
19#pragma once
20
21#include "C4GroupSet.h"
22#include "StdBuf.h"
23#include "StdFile.h"
24
25class C4ComponentHost
26{
27public:
28 C4ComponentHost();
29 virtual ~C4ComponentHost();
30 const char *GetFilePath() const { return FilePath; }
31 void Default();
32 void Clear();
33 const char *GetData() const { return Data.getData(); }
34 size_t GetDataSize() const { return Data.getLength(); }
35 virtual void Close();
36 bool Load(const char *szName, C4Group &hGroup, const char *szFilename, const char *szLanguage = nullptr);
37 bool Load(const char *szName, C4GroupSet &hGroupSet, const char *szFilename, const char *szLanguage = nullptr);
38 bool LoadEx(const char *szName, C4Group &hGroup, const char *szFilename, const char *szLanguage = nullptr);
39 bool LoadAppend(const char *szName, C4Group &hGroup, const char *szFilename, const char *szLanguage = nullptr);
40 bool Save(C4Group &hGroup);
41 bool GetLanguageString(const char *szLanguage, class StdStrBuf &rTarget);
42 void TrimSpaces();
43
44#ifdef _WIN32
45 void ShowDialog(HWND parent);
46
47private:
48 static INT_PTR CALLBACK ComponentDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
49#endif
50
51protected:
52 StdStrBuf Data;
53 bool Modified;
54 char Name[_MAX_FNAME + 1];
55 char Filename[_MAX_FNAME + 1];
56 char FilePath[_MAX_PATH + 1];
57 void CopyFilePathFromGroup(const C4Group &hGroup);
58};
59