Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- APIs
- os.loadAPI("functionsAPI");
- -- Variablen
- setNewButton = false; -- Kann ein neuer Knopf gesetzt werden?
- fXPos = 0; -- First X Position
- sXPos = 0; -- Second X Position
- fYPos = 0; -- First Y Position
- sYPos = 0; -- Second Y Position
- dateiOpen = false; -- Ist Datei geöffnet?
- bearbeitenOpen = false; -- Ist Bearbeiten geöffnet?
- progName = "newButtonProg"; -- Programmname
- tColor = colors.white; -- Text Color
- hColor = colors.gray; -- Header (Kopfzeile) Color
- bColor = colors.white; -- Background Color
- userBackground = colors.black; -- Hintergrund in den Einstellungen
- userTextColor = colors.white; -- Text Farbe in den Einstellungen
- menuBar = true; -- Menu Bar ausgeklappt?
- invisible = false; -- Knöpfe sichtbar?
- buttonsTable = {}; -- Button Tabelle
- -- local Knöpfe Koords
- dateiX = {1, 5};
- dateiY = {1, 1};
- bearbeitenX = {7, 16};
- bearbeitenY = {1, 1};
- foldMenuX = {48, 48};
- foldMenuY = {1, 1};
- neuX = {1, 19};
- neuY = {2, 2};
- speichernX = {1, 19};
- speichernY = {3, 3};
- projektSpeichernX = {1,19};
- projektSpeichernY = {4,4};
- projektLadenX = {1,19};
- projektLadenY = {5,5};
- undoX = {7, 19};
- undoY = {2, 2};
- optionsX = {7, 19};
- optionsY = {3, 3};
- quitX = {51, 51};
- quitY = {1, 1};
- helpX = {50, 50};
- helpY = {1, 1};
- -- Grafischer Teil
- term.clear();
- mainWindow = paintutils.loadImage(".mainWindow");
- paintutils.drawImage(mainWindow, 1, 1);
- progName = functionsAPI.prog_setProgName();
- functionsAPI.design_fillMon("X", bColor, menuBar);
- if menuBar then
- term.setCursorPos(1,1);
- term.setBackgroundColor(hColor);
- term.setTextColor(tColor)
- term.write(" ");
- term.setCursorPos(1,1);
- term.write("Datei Bearbeiten ^ ?");
- term.setBackgroundColor(colors.red);
- term.write("X");
- term.setBackgroundColor(bColor);
- end
- -- Programmtechnischer Teil
- while true do
- event, side, x, y = os.pullEvent();
- if (event == "mouse_click") then
- if (functionsAPI.object_checkIfClicked(dateiX, dateiY, x, y) and menuBar) then
- if (bearbeitenOpen) then
- bearbeitenOpen = false;
- end
- dateiOpen = functionsAPI.design_dateiMenu(dateiOpen, tColor, hColor, bColor, buttonsTable, menuBar, invisible);
- setNewButton = false;
- elseif (functionsAPI.object_checkIfClicked(bearbeitenX, bearbeitenY, x, y) and menuBar) then
- if (dateiOpen) then
- dateiOpen = false;
- end
- bearbeitenOpen = functionsAPI.design_bearbeitenMenu(bearbeitenOpen, tColor, hColor, bColor, buttonsTable, menuBar, invisible);
- setNewButton = false;
- elseif (functionsAPI.object_checkIfClicked(foldMenuX, foldMenuY, x, y) and menuBar) then
- menuBar = false;
- functionsAPI.design_redrawMonitor(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- elseif (functionsAPI.object_checkIfClicked(neuX, neuY, x, y) and dateiOpen) then
- setNewButton = false;
- fXPos = 0;
- sXPos = 0;
- fYPos = 0;
- sYPos = 0;
- dateiOpen = false;
- bearbeitenOpen = false;
- progName = "";
- progCode = "";
- buttonsTable = {};
- progName = functionsAPI.prog_setProgName();
- dateiOpen,bearbeitenOpen = functionsAPI.prog_closeMenus(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- elseif (functionsAPI.object_checkIfClicked(speichernX, speichernY, x, y) and dateiOpen) then
- functionsAPI.prog_compileObjects(buttonsTable, progName, userBackground, userTextColor);
- dateiOpen,bearbeitenOpen = functionsAPI.prog_closeMenus(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- term.setBackgroundColor(colors.gray);
- term.setCursorPos(36,1)
- term.write("Gespeichert");
- elseif (functionsAPI.object_checkIfClicked(projektSpeichernX, projektSpeichernY, x, y) and dateiOpen) then
- saved = functionsAPI.prog_saveProject(buttonsTable, progName, userBackground, userTextColor);
- dateiOpen,bearbeitenOpen = functionsAPI.prog_closeMenus(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- if saved then
- term.setBackgroundColor(colors.gray);
- term.setCursorPos(28,1)
- term.write("Projekt gespeichert");
- else
- term.setBackgroundColor(colors.gray);
- term.setCursorPos(33,1)
- term.write("Fehlgeschlagen");
- end
- elseif (functionsAPI.object_checkIfClicked(projektLadenX, projektLadenY, x, y) and dateiOpen) then
- choosedProject = "";
- choosedProject = functionsAPI.prog_loadProject();
- if choosedProject == "" then
- dateiOpen,bearbeitenOpen = functionsAPI.prog_closeMenus(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- else
- file = fs.open(choosedProject, "r");
- fileCode = textutils.unserialise(file.readAll());
- if (fileCode ~= nil) and (fileCode[1] ~= nil) then
- progName = fileCode[1];
- userBackground = fileCode[2];
- userTextColor = fileCode[3];
- buttonsTable = fileCode[4];
- dateiOpen,bearbeitenOpen = functionsAPI.prog_closeMenus(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(32,1);
- term.write("Projekt geladen");
- else
- dateiOpen,bearbeitenOpen = functionsAPI.prog_closeMenus(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- term.setBackgroundColor(colors.gray);
- term.setCursorPos(27,1);
- term.write("Laden fehlgeschlagen");
- end
- file.close()
- end
- elseif (functionsAPI.object_checkIfClicked(undoX, undoY, x, y) and bearbeitenOpen) then
- functionsAPI.object_undoLastObject(buttonsTable, hColor, tColor, bColor, menuBar, invisible);
- dateiOpen,bearbeitenOpen = functionsAPI.prog_closeMenus(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- elseif (functionsAPI.object_checkIfClicked(optionsX, optionsY, x, y) and bearbeitenOpen) then
- userTextColor, userBackground = functionsAPI.prog_changeSettings(buttonsTable, hColor, tColor, bColor, userTextColor, userBackground, menuBar, invisible);
- dateiOpen,bearbeitenOpen = functionsAPI.prog_closeMenus(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- elseif (functionsAPI.object_checkIfClicked(quitX, quitY, x, y) and menuBar) then
- term.setBackgroundColor(colors.black);
- term.setTextColor(colors.white);
- term.clear();
- term.setCursorPos(1,1);
- term.write("Danke, fuer das benutzen des ButtonCreators! :-\)");
- term.setCursorPos(1,2);
- break;
- elseif (functionsAPI.object_checkIfClicked(helpX, helpY, x, y) and menuBar) then
- functionsAPI.design_helpMenu(buttonsTable, bColor, hColor, tColor, menuBar);
- else
- if ((y ~= 1 and menuBar) or (not menuBar)) then
- if (setNewButton == false) then
- dateiOpen,bearbeitenOpen = functionsAPI.prog_closeMenus(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- fXPos = x;
- fYPos = y;
- term.setCursorPos(x,y);
- term.setTextColor(colors.black);
- term.setBackgroundColor(bColor);
- term.write("X");
- term.setTextColor(tColor);
- setNewButton = true;
- elseif (setNewButton == true) then
- sXPos = x;
- sYPos = y;
- tempButtonTable = {};
- buttonText = "";
- buttonColor = "";
- term.setCursorPos(x,y);
- term.setTextColor(colors.black);
- term.setBackgroundColor(bColor);
- term.write("X");
- term.setTextColor(tColor);
- --if (fXPos ~= sXPos and fYPos ~= sYPos) then
- if (fXPos > sXPos) then
- local newFXPos = sXPos;
- sXPos = fXPos;
- fXPos = newFXPos;
- end
- if (fYPos > sYPos) then
- local newFYPos = sYPos;
- sYPos = fYPos;
- fYPos = newFYPos;
- end
- local saved = false
- buttonText, buttonColor, buttonTextColor, saved = functionsAPI.prog_setButtonSettings(fXPos, sXPos);
- if saved then
- table.insert(tempButtonTable, 1, buttonText);
- table.insert(tempButtonTable, 2, buttonColor);
- table.insert(tempButtonTable, 3, buttonTextColor);
- functionsAPI.design_redrawMonitor(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- shell.run("edit temp.lua");
- table.insert(tempButtonTable, 4, fXPos);
- table.insert(tempButtonTable, 5, fYPos);
- table.insert(tempButtonTable, 6, sXPos);
- table.insert(tempButtonTable, 7, sYPos);
- if fs.exists("temp.lua") then
- file = fs.open("temp.lua","r");
- tempCode = file.readAll();
- file.close()
- fs.delete("temp.lua");
- table.insert(tempButtonTable, 8, tempCode);
- table.insert(buttonsTable, tempButtonTable[1]);
- table.insert(buttonsTable, tempButtonTable[2]);
- table.insert(buttonsTable, tempButtonTable[3]);
- table.insert(buttonsTable, tempButtonTable[4]);
- table.insert(buttonsTable, tempButtonTable[5]);
- table.insert(buttonsTable, tempButtonTable[6]);
- table.insert(buttonsTable, tempButtonTable[7]);
- table.insert(buttonsTable, tempButtonTable[8]);
- end
- functionsAPI.design_redrawMonitor(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- setNewButton = false;
- else
- setNewButton = false;
- functionsAPI.design_redrawMonitor(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- end
- --[[else
- setNewButton = false;
- functionsAPI.design_redrawMonitor(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- end]]--
- end
- end
- end
- elseif (event == "char") then
- if (side == "l") then
- if not menuBar then
- menuBar = true;
- else
- menuBar = false;
- end
- functionsAPI.design_redrawMonitor(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- elseif (side == "k") then
- if invisible then
- invisible = false;
- else
- invisible = true;
- end
- functionsAPI.design_redrawMonitor(buttonsTable, bColor, hColor, tColor, menuBar, invisible);
- end
- end
- end
- -- Scripted by Streetboy_xD
- -- Please keep this text in the program.
Add Comment
Please, Sign In to add comment