15 cv2
TILE_V2(TILE_SIZE
, TILE_SIZE
);
18 int Main (int, char **) {
19 festring OldDirectory
;
20 std::ifstream
IConfigFile(".igor.rc");
21 if (IConfigFile
.is_open()) {
23 while (IConfigFile
.get(ch
)) OldDirectory
<< ch
;
26 std::cout
<< "Where is the graphics directory? ";
28 if (OldDirectory
.GetSize()) std::cout
<< '[' << OldDirectory
.CStr() << "] ";
32 while ((ch
= getchar()) != '\n') Directory
<< ch
;
34 if (Directory
.IsEmpty()) Directory
= OldDirectory
;
35 if (!Directory
.IsEmpty() && Directory
[Directory
.GetSize()-1] != '/') Directory
<< '/';
37 std::ofstream
OConfigFile(".igor.rc");
38 OConfigFile
<< Directory
.CStr();
42 graphics::SetMode("IGOR 1.203", 0, v2(800, 600), false);
43 graphics::LoadDefaultFont(Directory
+"Font.pcx");
44 DOUBLE_BUFFER
->ClearToColor(0);
47 felist
List(CONST_S("Choose file to edit:"));
48 List
.AddEntry(CONST_S("Char.pcx"), LIGHT_GRAY
);
49 List
.AddEntry(CONST_S("Humanoid.pcx"), LIGHT_GRAY
);
50 List
.AddEntry(CONST_S("Item.pcx"), LIGHT_GRAY
);
51 List
.AddEntry(CONST_S("GLTerra.pcx"), LIGHT_GRAY
);
52 List
.AddEntry(CONST_S("OLTerra.pcx"), LIGHT_GRAY
);
55 List
.SetPos(v2(300, 250));
57 while ((Selected
= List
.Draw()) & FELIST_ERROR_BIT
) if(Selected
== ESCAPED
) return 0;
59 case 0: FileName
= CONST_S("Char.pcx"); break;
60 case 1: FileName
= CONST_S("Humanoid.pcx"); break;
61 case 2: FileName
= CONST_S("Item.pcx"); break;
62 case 3: FileName
= CONST_S("GLTerra.pcx"); break;
63 case 4: FileName
= CONST_S("OLTerra.pcx"); break;
65 CBitmap
= new rawbitmap(Directory
+ FileName
);
66 bitmap
CursorBitmap(Directory
+"Cursor.pcx");
67 CursorBitmap
.ActivateFastFlag();
71 packcol16 Color
[4] = { MakeRGB16(47, 131, 95), MakeRGB16(123, 0, 127), MakeRGB16(0, 131, 131), MakeRGB16(175, 131, 0) };
72 std::vector
<v2
> DrawQueue
;
73 uChar TempBuffer
[256];
77 { RES
.X
- STRETCH
* 16 - 10, RES
.Y
- STRETCH
* 16 - 10 },
78 { TILE_SIZE
, TILE_SIZE
},
84 { RES
.X
- STRETCH
* 32 - 20, RES
.Y
- STRETCH
* 16 - 10 },
85 { TILE_SIZE
, TILE_SIZE
},
92 { TILE_SIZE
, TILE_SIZE
},
98 static v2 MoveVector
[] = { v2(0, -16), v2(-16, 0), v2(0, 16), v2(16, 0) };
99 static int Key
[] = { 'w', 'a', 's', 'd' };
101 for (c
= 0; c
< 4; ++c
) {
103 v2 NewPos
= Cursor
+MoveVector
[c
];
104 if (NewPos
.X
>= 0 && NewPos
.X
<= CBitmap
->GetSize().X
-16 &&
105 NewPos
.Y
>= 0 && NewPos
.Y
<= CBitmap
->GetSize().Y
-16) Cursor
= NewPos
;
108 if ((Key
[c
]&~0x20) == k
) {
109 v2 NewPos
= Cursor
+(MoveVector
[c
]<<2);
110 if (NewPos
.X
>= 0 && NewPos
.X
<= CBitmap
->GetSize().X
-16 &&
111 NewPos
.Y
>= 0 && NewPos
.Y
<= CBitmap
->GetSize().Y
-16) Cursor
= NewPos
;
115 if (k
>= 0x31 && k
<= 0x34) Selected
= k
-0x31;
116 else if (k
== '+') CBitmap
->AlterGradient(Cursor
, TILE_V2
, Selected
, 1, false);
117 else if (k
== '-') CBitmap
->AlterGradient(Cursor
, TILE_V2
, Selected
, -1, false);
118 else if (k
== '>') CBitmap
->AlterGradient(Cursor
, TILE_V2
, Selected
, 1, true);
119 else if (k
== '<') CBitmap
->AlterGradient(Cursor
, TILE_V2
, Selected
, -1, true);
120 else if (k
== KEY_UP
) CBitmap
->Roll(Cursor
, TILE_V2
, v2(0, -1), TempBuffer
);
121 else if (k
== KEY_DOWN
) CBitmap
->Roll(Cursor
, TILE_V2
, v2(0, 1), TempBuffer
);
122 else if (k
== KEY_RIGHT
) CBitmap
->Roll(Cursor
, TILE_V2
, v2(1, 0), TempBuffer
);
123 else if (k
== KEY_LEFT
) CBitmap
->Roll(Cursor
, TILE_V2
, v2(-1, 0), TempBuffer
);
125 FONT
->Printf(DOUBLE_BUFFER
, v2(10, 460), RED
, "Select col to swap with [1-4/ESC]");
126 graphics::BlitDBToScreen();
127 for (k
= GET_KEY(); k
!= 0x1B; k
= GET_KEY()) {
128 if (k
>= 0x31 && k
<= 0x34) {
129 CBitmap
->SwapColors(Cursor
, TILE_V2
, Selected
, k
- 0x31);
133 } else if (k
== 0x1B) {
134 FONT
->Printf(DOUBLE_BUFFER
, v2(10, 460), RED
, "Save? [y/n/c]");
135 graphics::BlitDBToScreen();
138 if (k
== 'y' || k
== 'Y') {
139 CBitmap
->Save(Directory
+ FileName
);
143 if (k
== 'n' || k
== 'N') {
147 if (k
== 'c' || k
== 'C') break;
149 } else if (k
== 'p') {
150 std::vector
<v2
>::iterator i
= std::find(DrawQueue
.begin(), DrawQueue
.end(), Cursor
);
151 if (i
== DrawQueue
.end()) DrawQueue
.push_back(Cursor
); else DrawQueue
.erase(i
);
152 } else if (k
== 'c') {
156 DOUBLE_BUFFER
->ClearToColor(0);
157 DOUBLE_BUFFER
->Fill(0, 0, CBitmap
->GetSize(), 0xF81F);
158 CBitmap
->MaskedBlit(DOUBLE_BUFFER
, v2(0, 0), v2(0, 0), CBitmap
->GetSize(), Color
);
159 DOUBLE_BUFFER
->DrawRectangle(RES
.X
-STRETCH
*16-12, RES
.Y
-STRETCH
*16-12, RES
.X
-9, RES
.Y
-9, DARK_GRAY
, true);
160 DOUBLE_BUFFER
->DrawRectangle(RES
.X
-STRETCH
*32-22, RES
.Y
-STRETCH
*16-12, RES
.X
-STRETCH
*16-19, RES
.Y
-9, DARK_GRAY
, true);
162 DOUBLE_BUFFER
->StretchBlit(B1
);
163 FONT
->Printf(DOUBLE_BUFFER
, v2(10, 480), WHITE
, "Control cursor: wasd and WASD");
164 FONT
->Printf(DOUBLE_BUFFER
, v2(10, 490), WHITE
, "Select m-col: 1-4");
165 FONT
->Printf(DOUBLE_BUFFER
, v2(10, 500), WHITE
, "Safely alter gradient: ±");
166 FONT
->Printf(DOUBLE_BUFFER
, v2(10, 510), WHITE
, "Power alter gradient: <>");
167 FONT
->Printf(DOUBLE_BUFFER
, v2(10, 520), WHITE
, "Swap m-cols: =");
168 FONT
->Printf(DOUBLE_BUFFER
, v2(10, 530), WHITE
, "Push to / pop from draw queue: p");
169 FONT
->Printf(DOUBLE_BUFFER
, v2(10, 540), WHITE
, "Clear draw queue: c");
170 FONT
->Printf(DOUBLE_BUFFER
, v2(10, 550), WHITE
, "Roll picture: arrow keys");
171 FONT
->Printf(DOUBLE_BUFFER
, v2(10, 570), WHITE
, "MColor selected: %d", Selected
+ 1);
172 FONT
->Printf(DOUBLE_BUFFER
, v2(10, 580), WHITE
, "Current position: (%d, %d)", Cursor
.X
, Cursor
.Y
);
174 for (c
= 0; c
< (int)DrawQueue
.size(); ++c
) {
175 B2
.Src
= DrawQueue
[c
];
176 DOUBLE_BUFFER
->StretchBlit(B2
);
177 B3
.Dest
= DrawQueue
[c
];
178 CursorBitmap
.NormalMaskedBlit(B3
);
182 CursorBitmap
.NormalMaskedBlit(B3
);
183 graphics::BlitDBToScreen();