forked from leuat/TRSE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imageworker.cpp
178 lines (155 loc) · 10.1 KB
/
imageworker.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
* Turbo Rascal Syntax error, “;” expected but “BEGIN” (TRSE, Turbo Rascal SE)
* 8 bit software development IDE for the Commodore 64
* Copyright (C) 2018 Nicolaas Ervik Groeneboom ([email protected])
*
*
* 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 (LICENSE.txt).
* If not, see <https://www.gnu.org/licenses/>.
*/
#include "imageworker.h"
#include <QDebug>
#include <QStandardItemModel>
ImageWorker::ImageWorker()
{
m_types.append(ImageType("CGA png Palette 1", "X86",LImage::Type::CGA, LColorList::Type::CGA1_HIGH));
m_types.append(ImageType("CGA hires", "X86",LImage::Type::CGA_HIRES, LColorList::Type::MONO));
m_types.append(ImageType("Amiga 320x256", "AMIGA",LImage::Type::AMIGA320x256, LColorList::Type::C64));
m_types.append(ImageType("Amiga 320x200", "AMIGA",LImage::Type::AMIGA320x200, LColorList::Type::C64));
m_types.append(ImageType("MultiColor bitmap", "C64", LImage::Type::MultiColorBitmap,LColorList::Type::C64));
m_types.append(ImageType("Custom (large) MultiColor bitmap", "C64", LImage::Type::CustomC64,LColorList::Type::C64));
m_types.append(ImageType("Hires Bitmap", "C64",LImage::Type::HiresBitmap,LColorList::Type::C64));
m_types.append(ImageType("Charmap", "C64",LImage::Type::CharMapMulticolor,LColorList::Type::C64));
// m_types.append(ImageType("Hires Charmap", "c64",LImage::Type::CharmapRegular,LColorList::Type::C64));
m_types.append(ImageType("Charmap", "VIC20",LImage::Type::CharMapMulticolor,LColorList::Type::C64));
m_types.append(ImageType("PBM Image", "PET",LImage::Type::CharMapMulticolor,LColorList::Type::C64));
m_types.append(ImageType("Level Editor", "PET",LImage::Type::LevelEditor,LColorList::Type::C64));
// m_types.append(ImageType("Hires Charmap", "vic20",LImage::Type::CharmapRegular,LColorList::Type::C64));
m_types.append(ImageType("Screen animation", "C64",LImage::Type::FullScreenChar,LColorList::Type::C64));
m_types.append(ImageType("Screen animation", "VIC20",LImage::Type::FullScreenChar,LColorList::Type::C64));
m_types.append(ImageType("Level Editor", "C64",LImage::Type::LevelEditor,LColorList::Type::C64));
m_types.append(ImageType("Sprite Editor", "C64",LImage::Type::Sprites2,LColorList::Type::C64));
m_types.append(ImageType("Multicolor bitmap", "VIC20",LImage::Type::VIC20_MultiColorbitmap,LColorList::Type::VIC20));
m_types.append(ImageType("Level Editor", "VIC20",LImage::Type::LevelEditor,LColorList::Type::C64));
m_types.append(ImageType("OK64 Image", "OK64",LImage::Type::OK64_256x256,LColorList::Type::OK64));
m_types.append(ImageType("X16 640x480 Image", "X16",LImage::Type::X16_640x480,LColorList::Type::X16));
m_types.append(ImageType("PICO 8", "PICO-8",LImage::Type::QImageBitmap, LColorList::Type::PICO8));
m_types.append(ImageType("NES CHR/tiles", "NES",LImage::Type::NES, LColorList::Type::NES));
m_types.append(ImageType("Meta Tile Editor", "NES",LImage::Type::LMetaChunk, LColorList::Type::NES));
m_types.append(ImageType("Meta Tile Editor", "C64",LImage::Type::LMetaChunk, LColorList::Type::NES));
m_types.append(ImageType("Meta Tile Editor", "VIC20",LImage::Type::LMetaChunk, LColorList::Type::NES));
m_types.append(ImageType("NES Meta Sprite editor", "NES",LImage::Type::SpritesNES, LColorList::Type::NES));
m_types.append(ImageType("NES Level Editor", "NES",LImage::Type::LevelEditorNES,LColorList::Type::NES));
m_types.append(ImageType("Fake C64 png Palette 1", "C64",LImage::Type::QImageBitmap, LColorList::Type::C64));
m_types.append(ImageType("Fake C64 png Palette 2", "C64",LImage::Type::QImageBitmap, LColorList::Type::C64_ORG));
m_types.append(ImageType("Sprite Editor (deprecated type)","C64", LImage::Type::Sprites,LColorList::Type::C64));
m_types.append(ImageType("Gameboy CHR/tiles", "GAMEBOY",LImage::Type::GAMEBOY, LColorList::Type::NES));
m_types.append(ImageType("Meta Tile Editor", "GAMEBOY",LImage::Type::LMetaChunk, LColorList::Type::NES));
m_types.append(ImageType("Gameboy Level Editor", "gameboy",LImage::Type::LevelEditorGameboy,LColorList::Type::NES));
m_types.append(ImageType("320x200 16 color Atari ST", "atari520st",LImage::Type::ATARI320x200,LColorList::Type::C64));
m_types.append(ImageType("160x200 16 color Amstrad CPC", "amstradcpc",LImage::Type::AmstradCPC,LColorList::Type::AMSTRADCPC));
m_types.append(ImageType("Amstrad CPC sprites", "amstradcpc",LImage::Type::AmstradSprites,LColorList::Type::AMSTRADCPC));
m_types.append(ImageType("generic NxM color Amstrad", "amstradcpc",LImage::Type::AmstradCPCGeneric,LColorList::Type::AMSTRADCPC));
m_types.append(ImageType("BBC Image", "bbcm",LImage::Type::BBC,LColorList::Type::BBC));
m_types.append(ImageType("VGA 320x200", "x86",LImage::Type::VGA, LColorList::Type::VGA));
m_types.append(ImageType("ZX Spectrum 256x192", "spectrum",LImage::Type::Spectrum, LColorList::Type::SPECTRUM));
m_types.append(ImageType("SNES tilemap/sprites", "snes",LImage::Type::SNES, LColorList::Type::SNES));
m_types.append(ImageType("SNES Level editor", "snes",LImage::Type::LevelEditorSNES, LColorList::Type::SNES));
m_types.append(ImageType("SNES generic image", "snes",LImage::Type::SNESGeneric, LColorList::Type::SNES));
m_types.append(ImageType("VZ200 mode 1 (128x64)", "vz200",LImage::Type::VZ200, LColorList::Type::VZ200));
m_types.append(ImageType("JDH8", "jdh8",LImage::Type::JDH8, LColorList::Type::CGA1_HIGH));
m_types.append(ImageType("Generic indexed image", "all",LImage::Type::LImageGeneric, LColorList::Type::C64));
m_types.append(ImageType("Generic 256-color sprites", "x16",LImage::Type::GenericSprites, LColorList::Type::VGA));
m_types.append(ImageType("CGA/EGA 160x100 16 colour", "x86",LImage::Type::CGA160x100, LColorList::Type::DOS));
m_types.append(ImageType("TIM 512x256", "TIM",LImage::Type::TIM, LColorList::Type::TIM));
m_types.append(ImageType("TIM generic image", "TIM",LImage::Type::TIMG, LColorList::Type::TIM));
m_types.append(ImageType("TVC generic", "TVC",LImage::Type::TVC, LColorList::Type::TVC));
m_types.append(ImageType("CoCo3 generic", "TRS80COCO",LImage::Type::COCO3, LColorList::Type::COCO3));
m_types.append(ImageType("Thomson generic", "THOMSON",LImage::Type::THOMSON, LColorList::Type::THOMSON));
m_types.append(ImageType("Level editor VZ200", "VZ200",LImage::Type::LevelEditorGeneric, LColorList::Type::VZ200));
m_types.append(ImageType("Level editor COCO3", "TRS80COCO",LImage::Type::LevelEditorGeneric, LColorList::Type::COCO3));
m_types.append(ImageType("Level editor VGA", "X86",LImage::Type::LevelEditorGeneric, LColorList::Type::VGA));
m_types.append(ImageType("Level editor AMIGA", "AMIGA",LImage::Type::LevelEditorGeneric, LColorList::Type::VGA));
m_types.append(ImageType("Level editor ATARI", "ATARI520ST",LImage::Type::LevelEditorGeneric, LColorList::Type::VGA));
m_types.append(ImageType("Agon generic", "AGON",LImage::Type::AGON, LColorList::Type::VGA));
m_types.append(ImageType("Primo generic", "PRIMO",LImage::Type::PRIMO, LColorList::Type::MONO));
// m_types.append(ImageType("Hybrid multicolor/hires charset", "c64",LImage::Type::HybridCharset,LColorList::Type::C64));
// m_types.append(ImageType("Hybrid multicolor/hires charset", "vic20",LImage::Type::HybridCharset,LColorList::Type::VIC20));
// m_types.append(ImageType("C64 Multicolor Charmap Fixed Colors", LImage::Type::CharMapMultiColorFixed,LColorList::Type::C64));
/* m_types.append(ImageType("CGA Palette 1 Lo", LImage::Type::QImageBitmap,LColorList::Type::CGA1_LOW));
m_types.append(ImageType("CGA Palette 1 Hi", LImage::Type::QImageBitmap,LColorList::Type::CGA1_HIGH));
m_types.append(ImageType("CGA Palette 2 Lo", LImage::Type::QImageBitmap,LColorList::Type::CGA2_LOW));
m_types.append(ImageType("CGA Palette 2 Hi", LImage::Type::QImageBitmap,LColorList::Type::CGA2_HIGH));
m_types.append(ImageType("TIFF", LImage::Type::Tiff,LColorList::Type::TIFF));
*/
//New(5,);
}
ImageWorker::~ImageWorker()
{
for (ImageEdit* ie: m_images)
delete ie;
m_images.clear();
}
ImageType *ImageWorker::findType(LImage::Type imageType, LColorList::Type colType)
{
for (int i=0;i<m_types.count();i++) {
ImageType* it=&m_types[i];
if (it->colorType==colType && it->type == imageType)
return it;
}
return nullptr;//&m_types[0];
}
void ImageWorker::UpdateListView(QListView *lst)
{
QStandardItemModel *model = new QStandardItemModel( m_images.count(), 1, nullptr);
for (int i=0;i<m_images.count();i++) {
QStandardItem *item = new QStandardItem(m_images[i]->m_name);
model->setItem(i,0, item);
}
lst->setModel(model);
}
QStringList ImageWorker::getImageTypes()
{
QStringList l;
for (ImageType it : m_types)
l<< it.name;
return l;
}
void ImageWorker::New(LImage *image, QString name)
{
/* ImageType* imageType = findType(image->m_type, image->m_colorList.m_type);
if (imageType == nullptr) {
qDebug() << "WTF NULLPTR imagetype ";
return;
}*/
m_currentImage = new ImageEdit(image, nullptr, name);
//m_currentImage = new ImageEdit(imageType, "New Image");
m_images.append(m_currentImage);
Data::data.redrawFileList = true;
Data::data.Redraw();
}
void ImageWorker::New(LImage* img, int image)
{
// exit(1);
m_currentImage = new ImageEdit(img, &m_types[image], "New Image");
m_currentImage->Initialize(img);
m_images.append(m_currentImage);
m_currentImage->m_fileName="";
Data::data.redrawFileList = true;
}
void ImageWorker::SetImage(int cur)
{
if (cur>=0 && cur<m_images.count())
m_currentImage = m_images[cur];
}