Skip to content
This repository has been archived by the owner on May 25, 2024. It is now read-only.

Commit

Permalink
Update NoteBox.c to v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
SpielProfessor authored Dec 22, 2023
1 parent ea996bc commit 2e555ac
Showing 1 changed file with 38 additions and 14 deletions.
52 changes: 38 additions & 14 deletions NoteBox.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

#include <raylib.h>

#include<math.h>
#define RAYGUI_IMPLEMENTATION
#include "headers/raygui.h"

Expand All @@ -16,6 +16,7 @@
#define OPEN_ON_START true
#define SAVE_ON_CLOSE true
#define REMOVE_DONE_ON_SAVE false
#define USE_CONFIG_FILE true
int theme=0;


Expand Down Expand Up @@ -68,7 +69,13 @@ static void removebutton(int x);
};

int boxes=1;

void updateTheme(){
if (theme==1){
GuiLoadStyleDark();
} else if (theme==0) {
GuiLoadStyleDefault();
}
}
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
Expand All @@ -78,13 +85,23 @@ int main()
//---------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
char version[]="1.1b";
char version[]="1.2";
char name[]="NoteBox";

SetConfigFlags(FLAG_WINDOW_RESIZABLE);
InitWindow(screenWidth, screenHeight, name);
SetWindowIcon(LoadImage("resources/icon-png.png"));

if (OPEN_ON_START){
openbutton();
}
if (USE_CONFIG_FILE && FileExists("config.txt")){
char* text=LoadFileText("config.txt");

theme=text[0]-'0';
updateTheme();
printf("Loaded: %s\n", text);
}
bool about=false;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
Expand All @@ -94,7 +111,8 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
// TODO: Implement required update logic
screenWidth=GetScreenWidth();
screenHeight=GetScreenHeight();
//----------------------------------------------------------------------------------

// Draw
Expand All @@ -114,7 +132,7 @@ int main()
if (GuiButton(layoutRecs[4], "About")) {if (about) {about=false;} else {about=true;}}

//----Draw notes----//
for (int i=0; i<screenHeight/32; i++){
for (int i=0; i<=boxes; i++){
if (GuiTextBox(notes[i], notesContent[i], 128, notesState[i])) notesState[i] = !notesState[i];
if (GuiCheckBox(checkmarks[i], NULL, &checked[i]));
if (GuiButton(removes[i], "x")) removebutton(i);
Expand Down Expand Up @@ -174,13 +192,15 @@ static void savebutton()
// New item button //
static void newbutton()
{
// create new item //
boxes++;
notes[boxes] = (Rectangle){ 32, 32*boxes+32, 336, 24 };
checkmarks[boxes] = (Rectangle){ 0, 32*boxes+32, 24, 24 };
notesState[boxes] = false;
checked[boxes] = false;
removes[boxes] = (Rectangle){375, 32*boxes+32, 24, 24};
if (boxes<(GetScreenHeight()-32)/32-1){
// create new item //
boxes++;
notes[boxes] = (Rectangle){ 32, 32*boxes+32, 336, 24 };
checkmarks[boxes] = (Rectangle){ 0, 32*boxes+32, 24, 24 };
notesState[boxes] = false;
checked[boxes] = false;
removes[boxes] = (Rectangle){375, 32*boxes+32, 24, 24};
}
}
// Open button logic
static void openbutton()
Expand Down Expand Up @@ -226,12 +246,16 @@ static void openbutton()
//----switch theme----//
static void themebutton(){
if (theme==0){
GuiLoadStyleDark();

theme=1;
} else if (theme==1) {
GuiLoadStyleDefault();

theme=0;
}
if (USE_CONFIG_FILE){
SaveFileText("config.txt", (char*)TextFormat("%d\n", theme));
}
updateTheme();
}

//----Remove items from list----//
Expand Down

0 comments on commit 2e555ac

Please sign in to comment.