Skip to content

Commit

Permalink
very close to finishing, fixed a few bugs + edit ptm
Browse files Browse the repository at this point in the history
  • Loading branch information
dtplsongithub authored Jun 9, 2024
1 parent 2dd84fe commit 36b8c4d
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 74 deletions.
38 changes: 19 additions & 19 deletions ChildApplet.pde
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@ class ChildApplet extends PApplet {
windowMove(150, 200);
windowResizable(false);
textFont(MSGothic20);
log.loaded(" childapplet");
((PGraphicsOpenGL)g).textureSampling(3);
log.loaded("childapplet");
}

public void draw() {
if (oldmenu != menu) {
windowTitle(menutitle[menu]);
try {
windowTitle(menutitle[menu]);
} catch (ArrayIndexOutOfBoundsException e) {
log.error("ArrayIndexOutOfBoundsException on changing window title");
}
log.log("switched to menu "+menu);
oldmenu = menu;
}
background(0);
renderButtons();
switch (menu) {
case 0: {
for (int i = 0; i<bglist.length; i++){
Expand Down Expand Up @@ -102,20 +106,9 @@ class ChildApplet extends PApplet {
log.warn("unknown editor option "+i);
}
}
} else {
switch (floor(edopset[i][0])) {
default: {
//log.error("unknown special editor option "+i);
//logexit();
}
}
}
}

// that little speech bubble thing

}
if (bigstepsappear) image(bigsteps.image, 717, 148);

break;
}
case 2: {
Expand Down Expand Up @@ -154,6 +147,7 @@ class ChildApplet extends PApplet {
break;
}
case 7: {
toolbox.checkDraw();
toolbox.render();
break;
}
Expand All @@ -168,15 +162,20 @@ class ChildApplet extends PApplet {
break;
}
default: {
text("the chances of you seeing this is very low and if you CAN see this please make a github issue and also tell me this: \nmenu:" + menu, 30, 100);
text("the chances of you seeing this is very\n low and if you CAN see this please\n make a github issue and also\n tell me this: \nmenu:" + menu, 30, 100);
}
}
textSize(32);
textFont(MSGothic32);
fill(0);
rect(0, 0, 999, 50);
fill(255);
text(menutitle[menu], 20, 20, this.width, 999);
textSize(20);
try {
text(menutitle[menu], 20, 20, this.width, 999);
} catch (ArrayIndexOutOfBoundsException e) {
log.error("ArrayIndexOutOfBoundsException on rendering title");
}
textFont(MSGothic20);
renderButtons();
}
public void keyPressed() {
if (menu == 5 || menu == 8 ) keyboardDetection(editor.keyCode, editor.key);
Expand All @@ -196,6 +195,7 @@ class ChildApplet extends PApplet {
windowMove(150, 200);
}
optionsCheckKeyPress(editor.keyCode);
if (key == ESC) logexit();
}
void option(float what, int i, int y) {
if (!(what <= edopset[i][0])) text("<", 600, y);
Expand Down
16 changes: 11 additions & 5 deletions button.pde
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Button[] buttons = new Button[12];
TextButton[] buttons = new TextButton[13];

class Button {
class TextButton {
String id, text;
int x, y, w, h, activeMenu;
boolean active = true, toggle = false, toggler = false;
public Button(String _id, int _x, int _y, int _w, int _h, String _text, int _menu) {
public TextButton(String _id, int _x, int _y, int _w, int _h, String _text, int _menu) {
this.id = _id;
this.x = _x;
this.y = _y;
Expand All @@ -23,6 +23,12 @@ class Button {
editor.rect(this.x, this.y, this.w, this.h);
editor.fill(0);
editor.text(this.text, this.x+10, this.y+20);
if (id == "editorPreviewMode" && toolbox.b[3].toggle) {
editor.fill(0, 127);
editor.rect(this.x, this.y, this.w, this.h);
editor.fill(255);
return;
}
if (this.checkIfHovered()) {
editor.fill(0, 127, 255, 127);
editor.rect(this.x, this.y, this.w, this.h);
Expand Down Expand Up @@ -81,13 +87,13 @@ class ImageButton {
}

void renderButtons() {
for (Button i: buttons) {
for (TextButton i: buttons) {
i.render();
}
}

void checkButtons() {
for (Button i: buttons) {
for (TextButton i: buttons) {
if (i.activeMenu != menu || !i.active) continue;
if (!i.checkIfHovered()) continue;
switch (i.id) {
Expand Down
Binary file added data/assets/down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/assets/left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/assets/right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/assets/up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/assets/zoomin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/assets/zoomout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 15 additions & 14 deletions ebgg.pde
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void setup() {
size(960, 720, P2D);
noStroke();
frameRate(30);
MSGothic20 = loadFont("MS-Gothic-32.vlw");
MSGothic32 = loadFont("MS-Gothic-32.vlw");
log.loaded("font MSGothic32");
MSGothic20 = loadFont("MS-Gothic-20.vlw");
log.loaded("font MSGothic20");
Expand All @@ -64,24 +64,25 @@ void setup() {
editor = new ChildApplet();
surface.setSize(960, 720);


windowMove(600, 200);
windowResizable(false);

buttons[0] = new Button("01_name", 600, 75, 160, 30, "click to edit", 1);
buttons[1] = new Button("01_pal", 600, 105, 160, 30, "click to edit", 1);
buttons[2] = new Button("01_ptm", 600, 315, 160, 30, "click to edit", 1);
buttons[3] = new Button("save", 30, 200, 100, 30, "go back", 5);
buttons[4] = new Button("save", 30, 680, 100, 30, "go back", 6);
buttons[5] = new Button("save", 30, 680, 100, 30, "go back", 7);
buttons[6] = new Button("saveBackground", 30, 650, 100, 30, "save", 1);
buttons[7] = new Button("cancelOverwrite", 600, 650, 100, 30, "cancel", 1);
buttons[0] = new TextButton("01_name", 600, 75, 160, 30, "click to edit", 1);
buttons[1] = new TextButton("01_pal", 600, 105, 160, 30, "click to edit", 1);
buttons[2] = new TextButton("01_ptm", 600, 315, 160, 30, "click to edit", 1);
buttons[3] = new TextButton("save", 30, 200, 100, 30, "go back", 5);
buttons[4] = new TextButton("save", 30, 680, 100, 30, "go back", 6);
buttons[5] = new TextButton("save", 30, 680, 100, 30, "go back", 7);
buttons[6] = new TextButton("saveBackground", 30, 650, 100, 30, "save", 1);
buttons[7] = new TextButton("cancelOverwrite", 600, 650, 100, 30, "cancel", 1);
buttons[7].active = false;
buttons[8] = new Button("cancelExit", 600, 650, 100, 30, "cancel", 1);
buttons[8] = new TextButton("cancelExit", 600, 650, 100, 30, "cancel", 1);
buttons[8].active = false;
buttons[8] = new Button("createPaletteColor", 600, 680, 260, 30, "create new palette color", 6);
buttons[9] = new Button("savePaletteColor", 600, 680, 260, 30, "save palette color", 8);
buttons[10] = new Button("deletePaletteColor", 600, 650, 260, 30, "delete this palette color", 6);
buttons[11] = new Button("editPaletteColor", 600, 620, 260, 30, "edit this palette color", 6);
buttons[9] = new TextButton("createPaletteColor", 600, 680, 260, 30, "create new palette color", 6);
buttons[10] = new TextButton("savePaletteColor", 600, 680, 260, 30, "save palette color", 8);
buttons[11] = new TextButton("deletePaletteColor", 600, 650, 260, 30, "delete this palette color", 6);
buttons[12] = new TextButton("editPaletteColor", 600, 620, 260, 30, "edit this palette color", 6);


// load assets
Expand Down
138 changes: 102 additions & 36 deletions editor.pde
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ final String[] edopname = {
"dont switch the first n items",
"camera x velocity",
"camera y velocity",
"pallete map (or ptm)",
"palette map (or ptm)",
"scale",
"x wavyness frequency",
"interleaved x wavyness?",
Expand All @@ -20,66 +20,132 @@ Toolbox toolbox;

class Toolbox {
ImageButton[] ib;
Button[] b;
int currentToolSelected = 0;
TextButton[] b;
int currentToolSelected = 0, zoom = 0, scrollX=0, scrollY=0, currentColorSelected = 0;
boolean CANDRAW=false;
public Toolbox() {
ib = new ImageButton[6];
b = new Button[4];
ib[0] = new ImageButton("editorPencil", 30, 100, 7, "assets/pencil.png", 2);
ib[1] = new ImageButton("editorLine", 62, 100, 7, "assets/line.png", 2);
ib[2] = new ImageButton("editorRect", 94, 100, 7, "assets/rectangle.png", 2);
ib[3] = new ImageButton("editorFillRect", 126, 100, 7, "assets/filledRectangle.png", 2);
ib[4] = new ImageButton("editorCircle", 158, 100, 7, "assets/circle.png", 2);
ib[5] = new ImageButton("editorFillCircle", 190, 100, 7, "assets/filledCircle.png", 2);
b[0] = new Button("editorGrid", 222, 100, 110, 32, "Show grid", 7);
ib = new ImageButton[12];
b = new TextButton[4];
ib[0] = new ImageButton("editorPencil", 30, 68, 70, "assets/pencil.png", 2);
ib[1] = new ImageButton("editorLine", 62, 68, 70, "assets/line.png", 2);
ib[2] = new ImageButton("editorRect", 94, 68, 70, "assets/rectangle.png", 2);
ib[3] = new ImageButton("editorFillRect", 126, 68, 70, "assets/filledRectangle.png", 2);
ib[4] = new ImageButton("editorCircle", 158, 68, 70, "assets/circle.png", 2);
ib[5] = new ImageButton("editorFillCircle", 190, 68, 70, "assets/filledCircle.png", 2);
b[0] = new TextButton("editorGrid", 30, 100, 110, 32, "Show grid", 7);
b[0].toggler = true;
b[1] = new Button("editorStatusBar", 332, 100, 180, 32, "Show status bar", 7);
b[1] = new TextButton("editorStatusBar", 140, 100, 180, 32, "Show status bar", 7);
b[1].toggler = true;
b[1].toggle = true;
b[2] = new Button("editorPreviewMode", 512, 100, 230, 32, "Show numbers", 7);
b[2] = new TextButton("editorPreviewMode", 320, 100, 200, 32, "Don't use palette", 7);
b[2].toggler = true;
b[3] = new Button("editorUsePaloffset", 742, 100, 160, 32, "Use paloffset", 7);
b[3] = new TextButton("editorUsePaloffset", 520, 100, 160, 32, "Use paloffset", 7);
b[3].toggler = true;
ib[6] = new ImageButton("editorZoomIn", 872, 100, 7, "assets/zoomin.png", 2);
ib[7] = new ImageButton("editorZoomOut", 904, 100, 7, "assets/zoomout.png", 2);
ib[8] = new ImageButton("editorMoveL", 700, 100, 7, "assets/left.png", 2);
ib[8].active = false;
ib[9] = new ImageButton("editorMoveU", 732, 84, 7, "assets/up.png", 2);
ib[9].active = false;
ib[10] = new ImageButton("editorMoveD", 732, 116, 7, "assets/down.png", 2);
ib[10].active = false;
ib[11] = new ImageButton("editorMoveR", 764, 100, 7, "assets/right.png", 2);
ib[11].active = false;
}
public void render() {
for (ImageButton i: ib) i.render();
for (Button i: b) i.render();
editor.fill(0, 127, 255, 64);
editor.rect(this.currentToolSelected*32+30, 100, 32, 32);
int rs = floor(min(930/ptm[0].length, 440/ptm.length));
// editor.fill(0, 127, 255, 64);
// editor.rect(this.currentToolSelected*32+30, 68, 32, 32);
int rs = floor(min(900/ptm[0].length, 400/ptm.length))+zoom;
editor.noStroke();
for (int y = 0; y<ptm.length; y++) {
for (int x = 0; x<ptm[0].length; x++) {
if (b[3].toggle) {
if (ptm[y][x] < palssa) {
editor.fill(pal[ptm[y][x]]);
} else {
editor.fill(pal[rem(ptm[y][x]+paloffset, pal.length-palssa)+palssa]);
}
} else if (!b[2].toggle){
editor.fill(pal[ptm[y][x]]);
} else {
editor.colorMode(HSB, 100);
editor.fill(ptm[y][x]*4, 100, 70);
editor.colorMode(RGB, 255);
}
editor.rect(x*rs, y*rs+150, rs-int(b[0].toggle), rs-int(b[0].toggle));
this.getColor(ptm[y][x]);
editor.rect(x*rs+30+scrollX, y*rs+150+scrollY, rs-int(b[0].toggle), rs-int(b[0].toggle));
}
}
editor.fill(0);
editor.rect(0, 600, 999, 999);
editor.fill(255);
editor.text("Color picker", 30, 620);
int rp = 900/pal.length;
for (int i = 0; i<pal.length; i++) {
this.getColor(i);
editor.rect(30+i*rp, 650,rp, 30);
}
editor.stroke(0);
for (ImageButton i: ib) i.render();
for (TextButton i: b) i.render();
}
public void checkPress() {
for (int i = 0; i<ib.length; i++) {
ImageButton temp = ib[i];
if (temp.activeMenu != menu || !temp.active) continue;
if (!temp.checkIfHovered()) continue;
if (i != 6) currentToolSelected = i;
if (i < 6) currentToolSelected = i;
else {
switch (i) {
case 6:
this.zoom = 20;
for (int j=8;j<12;j++){
ib[j].active=true;
}
break;
case 7:
this.zoom = 0;
for (int j=8;j<12;j++){
ib[j].active=false;
}
scrollX=0;
scrollY=0;
break;
case +9:
case 10:
scrollY+=300*(int(i==10)*2-1);
break;
case +8:
case 11:
scrollX+=300*(int(i==11)*2-1);
break;
default: log.error("unknown toolbox imagebutton type "+i);
}
}
}
for (int i = 0; i<b.length; i++) {
Button temp = b[i];
TextButton temp = b[i];
if (temp.activeMenu != menu || !temp.active) continue;
if (!temp.checkIfHovered()) continue;
if (b[i].toggler) b[i].toggle=!b[i].toggle;
}
}
public void checkDraw() {
int rs = floor(min(900/ptm[0].length, 440/ptm.length))+zoom;
int rp = 900/pal.length;
if (editor.mousePressed) {
if (editor.mouseX >30+scrollX && editor.mouseX < ptm[0].length*rs+30+scrollX && editor.mouseY > 150+scrollY && editor.mouseY < ptm.length*rs+150+scrollY && CANDRAW) {
switch (currentToolSelected) {
default:
ptm[(editor.mouseY-150-scrollY)/rs][(editor.mouseX-30-scrollY)/rs] = this.currentColorSelected;
println("Good job!?");
break;
}
} else if (editor.mouseX>30 && editor.mouseX<900 && editor.mouseY>650 && editor.mouseY<680) {

}
} else CANDRAW = false;
}
private void getColor(int i) {
if (b[3].toggle) {
if (i < palssa) {
editor.fill(pal[i]);
} else {
editor.fill(pal[rem(i+paloffset, pal.length-palssa)+palssa]);
}
} else if (!b[2].toggle){
editor.fill(pal[i]);
} else {
editor.colorMode(HSB, 100);
editor.fill(i*4%100, 100, 70);
editor.colorMode(RGB, 255);
}
}
}

0 comments on commit 36b8c4d

Please sign in to comment.