comparison Interface.pde @ 131:9d17f991f102

Move undo and spare page management into buffers.pde as in Multipaint 2018.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 05 Aug 2018 10:44:45 +0300
parents b9b60552667e
children f5c32f6470d0
comparison
equal deleted inserted replaced
130:4d0bdd2b215d 131:9d17f991f102
180 mag = psize * 8; 180 mag = psize * 8;
181 return (height - (33 * g_uizoom)) / mag; //how many chars in a magmode 181 return (height - (33 * g_uizoom)) / mag; //how many chars in a magmode
182 } 182 }
183 183
184 184
185 void ustats() { 185 void sussborder()
186 //a debug thingie in case the step undo does not work
187 //println("UINDEX:"+g_uindex[g_spare]);
188 //println("UTOP:"+g_utop[g_spare]);
189 //println("UBOTTOM:"+g_ubottom[g_spare]);
190 }
191
192
193 void store_undo() //to_undo
194 { 186 {
195 if (g_spare)
196 arrayCopy(g_map, g_undobs[g_uindex[g_spare]]);
197 else
198 arrayCopy(g_map, g_undob[g_uindex[g_spare]]);
199
200 g_uindex[g_spare]++;
201 if (g_uindex[g_spare] > 10)
202 g_uindex[g_spare] = 0;
203
204 if (g_uindex[g_spare] == g_ubottom[g_spare]) {
205 g_ubottom[g_spare]++;
206 if (g_ubottom[g_spare] > 10)
207 g_ubottom[g_spare] = 0;
208 }
209 g_utop[g_spare] = g_uindex[g_spare];
210
211 refreshpalette();
212 ustats();
213 }
214
215
216 void restore_undo() {
217 if (g_uindex[g_spare] == g_ubottom[g_spare])
218 return;
219
220 if (g_spare)
221 arrayCopy(g_map, g_undobs[g_uindex[g_spare]]);
222 else
223 arrayCopy(g_map, g_undob[g_uindex[g_spare]]);
224
225 g_uindex[g_spare]--;
226 if (g_uindex[g_spare] < 0)
227 g_uindex[g_spare] = 10;
228
229 if (g_spare)
230 arrayCopy(g_undobs[g_uindex[g_spare]], g_map);
231 else
232 arrayCopy(g_undob[g_uindex[g_spare]], g_map);
233
234 refreshpalette();
235 ustats();
236 }
237
238
239 void redo_undo() {
240 if (g_uindex[g_spare] == g_utop[g_spare])
241 return;
242
243 g_uindex[g_spare]++;
244 if (g_uindex[g_spare] > 10)
245 g_uindex[g_spare] = 0;
246
247 if (g_spare)
248 arrayCopy(g_undobs[g_uindex[g_spare]], g_map);
249 else
250 arrayCopy(g_undob[g_uindex[g_spare]], g_map);
251
252 refreshpalette();
253 ustats();
254 }
255
256
257 void spare() //dpaint style spare page
258 {
259 arrayCopy(g_sparepage, g_swappage);
260 arrayCopy(g_map, g_sparepage);
261 arrayCopy(g_swappage, g_map);
262
263 mpSetTitle(g_spare ? sfilename : filename);
264
265 g_spare = 1 - g_spare;
266 g_realfront = byte(g_farge);
267 g_realback = byte(g_backg);
268 refreshpalette();
269 }
270
271
272 void switcher(int di) {
273 // this achieves varieties of whole screen copying
274 // needed for brush copy and pre-drawing the shapes when a
275 // tool is active etc.
276 switch (di) {
277 case 0:
278 arrayCopy(g_map, g_rmap);
279 break;
280 case 1:
281 arrayCopy(g_rmap, g_map);
282 for (int i = 0; i < 1024; i++) {
283 if (g_remdo[i] == 1) {
284 g_remdo[i] = 0;
285 g_redo[i] = 0;
286 }
287 }
288 break;
289 case 2:
290 arrayCopy(g_map, g_brush);
291 break;
292 case 3:
293 arrayCopy(g_map, g_sparepage);
294 break;
295 case 4:
296 arrayCopy(g_sparepage, g_mapm);
297 break;
298 }
299 }
300
301
302 void sussborder() {
303 makecolor(259, g_r[g_map[0]], g_g[g_map[0]], g_b[g_map[0]]); 187 makecolor(259, g_r[g_map[0]], g_g[g_map[0]], g_b[g_map[0]]);
304 g_boxreconstruct = 2; 188 g_boxreconstruct = 2;
305 } 189 }
306 190
307 191
308 void makecolor(int c, int rr, int gg, int bb) { 192 void makecolor(int c, int rr, int gg, int bb)
193 {
309 //0-255 go to g_map[] up until 1021-1023 194 //0-255 go to g_map[] up until 1021-1023
310 //the rest is not stored 195 //the rest is not stored
311 if (c < 256) { 196 if (c < 256) {
312 g_map[256 + c * 3] = byte(rr); 197 g_map[256 + c * 3] = byte(rr);
313 g_map[256 + c * 3 + 1] = byte(gg); 198 g_map[256 + c * 3 + 1] = byte(gg);
319 204
320 g_rgb[c] = 0xff000000 | ((rr & 0xff) << 16) | ((gg & 0xff) << 8) | (bb & 0xff); 205 g_rgb[c] = 0xff000000 | ((rr & 0xff) << 16) | ((gg & 0xff) << 8) | (bb & 0xff);
321 } 206 }
322 207
323 208
324 int fylli() { 209 int fylli()
210 {
325 //for the animated rubberband thingy 211 //for the animated rubberband thingy
326 g_rband++; 212 g_rband++;
327 if (g_rband > g_rbang) { 213 if (g_rband > g_rbang) {
328 g_rband = 0; 214 g_rband = 0;
329 g_rbang++; 215 g_rbang++;