Skip to content

Commit

Permalink
v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
lets-all-be-stupid-forever committed Jan 9, 2025
1 parent dd8fb04 commit 77fdb94
Show file tree
Hide file tree
Showing 26 changed files with 68 additions and 89 deletions.
29 changes: 16 additions & 13 deletions luasrc/app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,8 @@ initTutorial()

-- Loads each level
require 'levels.sandbox'
require 'levels.wires'
require 'levels.nand'
require 'levels.not'
require 'levels.and'
require 'levels.or'
require 'levels.xor'
require 'levels.mux'
require 'levels.decoder'
require 'levels.demux'
require 'levels.bus'
require 'levels.seven_seg'
require 'levels.adder'
require 'levels.subtractor'
require 'levels.comparator'
require 'levels.shifter'
require 'levels.mof3'
require 'levels.simple_ram'
require 'levels.collatz'
Expand All @@ -34,6 +21,22 @@ require 'levels.hanoi'
require 'levels.custom_components'
-- require 'levels.primes'


-- Legacy levels
-- require 'levels.legacy_levels.wires'
-- require 'levels.legacy_levels.nand'
-- require 'levels.legacy_levels.not'
-- require 'levels.legacy_levels.and'
-- require 'levels.legacy_levels.or'
-- require 'levels.legacy_levels.xor'
-- require 'levels.legacy_levels.mux'
-- require 'levels.legacy_levels.decoder'
-- require 'levels.legacy_levels.demux'
-- require 'levels.legacy_levels.adder'
-- require 'levels.legacy_levels.subtractor'
-- require 'levels.legacy_levels.comparator'
-- require 'levels.legacy_levels.shifter'

loadProgress()

setInitialLevelByName('Sandbox')
Expand Down
Binary file modified luasrc/imgs/levels/gcd_icon.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 luasrc/imgs/tutorial/tldr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 15 additions & 14 deletions luasrc/tutorial/init.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
-- tutorial stuff
return {
require 'tutorial.tldr',
require 'tutorial.basic',
--require 'tutorial.nand',
-- require 'tutorial.wire',
-- require 'tutorial.not',
-- require 'tutorial.and',
-- require 'tutorial.or',
-- require 'tutorial.xor',
-- require 'tutorial.mux',
-- require 'tutorial.demux',
-- require 'tutorial.decoder',
-- require 'tutorial.posint',
-- require 'tutorial.negint',
-- require 'tutorial.addition',
-- require 'tutorial.subtraction',
-- require 'tutorial.comparator',
require 'tutorial.nand',
require 'tutorial.wire',
require 'tutorial.not',
require 'tutorial.and',
require 'tutorial.or',
require 'tutorial.xor',
require 'tutorial.mux',
require 'tutorial.demux',
require 'tutorial.decoder',
require 'tutorial.posint',
require 'tutorial.negint',
require 'tutorial.addition',
require 'tutorial.subtraction',
require 'tutorial.comparator',
require 'tutorial.shifter',
require 'tutorial.srlatch',
require 'tutorial.dlatch',
Expand Down
9 changes: 9 additions & 0 deletions luasrc/tutorial/tldr.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
return {
name= "TL;DR",
text = [[
!img:imgs/tutorial/tldr.png
]]
}

9 changes: 0 additions & 9 deletions src/clip_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
#include "img.h"

Image ImageFromClipboard() {
#ifdef DEMO_VERSION
{
Image r = {0, 0, 0, 0, 0};
return r;
}
#endif
clip::image img;
if (!clip::get_image(img)) {
// std::cout << "Error getting image from clipboard\n";
Expand Down Expand Up @@ -57,9 +51,6 @@ Image ImageFromClipboard() {
}

void ImageToClipboard(Image img) {
#ifdef DEMO_VERSION
return;
#endif
clip::image_spec spec;
spec.width = img.width;
spec.height = img.height;
Expand Down
2 changes: 1 addition & 1 deletion src/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// (stb_image blocks at 8k by default)
#define MAX_IMG_SIZE (8 * 1024)
#else
#define MAX_IMG_SIZE 512
#define MAX_IMG_SIZE 256
#endif

#if defined(__linux__) || defined(__APPLE__)
Expand Down
6 changes: 3 additions & 3 deletions src/hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,10 @@ void HistSetBuffer(Hist* h, Image buffer) {
HistResetUndoHistory(h);
}

void HistNewBuffer(Hist* h) {
void HistNewBuffer(Hist* h, int bw, int bh) {
HistClearBufer(h);
int w = 128;
int hh = 128;
int w = bw;
int hh = bh;
h->buffer[0] = GenImageFilled(w, hh, BLANK);
h->buffer[1] = PyramidGenImage(h->buffer[0]);
h->buffer[2] = PyramidGenImage(h->buffer[1]);
Expand Down
2 changes: 1 addition & 1 deletion src/hist.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void HistUndo(Hist* h);
void HistRedo(Hist* h);

// Resets history and creates an empty image. (New button in the UI)
void HistNewBuffer(Hist* h);
void HistNewBuffer(Hist* h, int bw, int bh);

// Dispatchs an action to resize the image.
void HistActChangeImageSize(Hist* h, int deltax, int deltay);
Expand Down
10 changes: 2 additions & 8 deletions src/paint.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ void PaintRender(Paint* ca) {

void PaintNewBuffer(Paint* ca) {
PaintStopSimu(ca);
HistNewBuffer(&ca->h);
HistNewBuffer(&ca->h, 256, 256);
PaintResetCamera(ca);
}

Expand Down Expand Up @@ -1110,13 +1110,7 @@ void PaintHandleCameraMovement(Paint* ca) {
}
}

bool PaintGetIsDirty(Paint* ca) {
#ifdef DEMO_VERSION
return false;
#else
return HistGetIsDirty(&ca->h);
#endif
}
bool PaintGetIsDirty(Paint* ca) { return HistGetIsDirty(&ca->h); }

Image PaintGetSelBuffer(Paint* ca) { return HistGetSelBuffer(&ca->h); }

Expand Down
10 changes: 10 additions & 0 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
#define VERSION_H
#define CA_VERSION "v1.0.5 - 07Oct2024"

// v1.0.5 -->
// - Changed complete level icons
// - Splitted sandbox in sandbox and custom component levels.
// - Updated some icons (flag)
// - Updated UI of line tool: separation width has a dedicated button like the
// text tool.
// - Moved tutorial initial image to the tutorial section as TLDR section.
// - Removed dependency on levels so user can pick the one he wants directly.
// - Added a DEMO version with limited image size (256) to make freely
// available.
// v1.0.4 --> v1.0.4: Level Progression
// - Added Level Progression and Steam Achievements.
// - Added 2 dark colors to default palette
Expand Down
8 changes: 7 additions & 1 deletion src/w_about.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
#include "version.h"
#include "widgets.h"

#ifdef DEMO_VERSION
#define DEMO_STR "`Demo Version (max image size 256)`\n"
#else
#define DEMO_STR
#endif

static struct {
bool inited;
Textbox tb;
Expand Down Expand Up @@ -53,7 +59,7 @@ static void AboutUpdateLayout() {
void AboutOpen(Ui* ui) {
ui->window = WINDOW_ABOUT;
const char* about_page =
"\n!img:0\n\n" CA_VERSION
"\n!img:0\n\n" DEMO_STR CA_VERSION
"\n"
"A game by `lets_all_be_stupid_forever`.\n"
"[email protected]\n"
Expand Down
43 changes: 4 additions & 39 deletions src/w_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,10 @@ void MainInit(Ui* ui) {
C.header_size = 24 * ui->scale;
C.bottom_size = 3 * 17 * 1 * ui->scale - 6 * ui->scale;

#ifdef DEMO_VERSION
C.btn_save.disabled = true;
C.btn_saveas.disabled = true;
#endif

PaintLoad(&C.ca);
LevelOptions* opt = ApiGetLevelOptions();
if (!opt->startup_image_path) {
// This way here is not the same as MainLoadImageFromPath: when we load
// image this way, the image's path is not associated to it, so the user
// can't override the initial tutorial image directly by pressing "save".
Image img = LoadImage("../assets/tutorial.png");
PaintLoadImage(&C.ca, img);
PaintNewBuffer(&C.ca);
} else {
MainLoadImageFromPath(opt->startup_image_path);
}
Expand Down Expand Up @@ -185,11 +176,9 @@ void MainUpdateControls(Ui* ui) {
ui->debug = !ui->debug;
}

#ifndef DEMO_VERSION
if (IsKeyPressed(KEY_S) && IsKeyDown(KEY_LEFT_CONTROL)) {
MainOnSaveClick(ui, false);
}
#endif

bool mouse_on_target = MainGetIsCursorInTargeTimage() && ui->hit_count == 0;
C.mouse_on_target = mouse_on_target;
Expand Down Expand Up @@ -505,19 +494,9 @@ void MainDraw(Ui* ui) {
BtnDrawLegend(&C.btn_exit, bscale, "Exit");
BtnDrawLegend(&C.btn_sel_open, bscale, "Load Selection from Image");

#ifndef DEMO_VERSION
BtnDrawLegend(&C.btn_save, bscale, "Save Image (C-S)");
BtnDrawLegend(&C.btn_saveas, bscale, "Save Image As...");
BtnDrawLegend(&C.btn_sel_save, bscale, "Save Selection as Image");
#else
BtnDrawLegend(&C.btn_save, bscale,
"Save Image (C-S)\n`Not available in demo version.`");
BtnDrawLegend(&C.btn_saveas, bscale,
"Save Image As...\n`Not available in demo version.`");
BtnDrawLegend(&C.btn_sel_save, bscale,
"Save Selection as Image\n`Not available in demo version.`");

#endif

BtnDrawLegend(
&C.btn_simu, bscale,
Expand Down Expand Up @@ -748,7 +727,7 @@ void MainDrawErrorMessage(Ui* ui) {
void MainDrawStatusBar(Ui* ui) {
int ui_scale = ui->scale;
Color tc = WHITE;
int num_lines = 8;
int num_lines = 7;
int yc1 = (C.target_pos.y + C.img_target_tex.texture.height) / ui_scale -
19 * num_lines;
int xc = 1 * 4 + C.target_pos.x / ui_scale;
Expand Down Expand Up @@ -814,23 +793,12 @@ void MainDrawStatusBar(Ui* ui) {
}
}

LevelOptions* co = ApiGetLevelOptions();
LevelDesc* cd = ApiGetLevelDesc();
sprintf(txt, "[level] %s", co->options[cd->ilevel].name);
FontDrawTextureOutlined(txt, xc, yc7, tc, bg);

#ifndef DEMO_VERSION
const char* fname = GetFileName(MainGetFilename());
sprintf(txt, "[img] %s", fname);
FontDrawTextureOutlined(txt, xc, yc8, tc, bg);
#else
const char* msg = "[Demo] Full version available on Steam.";
FontDrawTextureOutlined(msg, xc, yc8, tc, RED);
#endif

FontDrawTextureOutlined(txt, xc, yc7, tc, bg);
Image img = PaintGetEditImage(&C.ca);
sprintf(txt, "[img] w: %d h: %d", img.width, img.height);
FontDrawTextureOutlined(txt, xc, yc9, tc, bg);
FontDrawTextureOutlined(txt, xc, yc8, tc, bg);
rlPopMatrix();
}

Expand Down Expand Up @@ -916,9 +884,6 @@ void MainUpdateWidgets() {

C.btn_sel_open.disabled = ned;
C.btn_sel_save.disabled = !has_sel || ned;
#ifdef DEMO_VERSION
C.btn_sel_save.disabled = true;
#endif

C.btn_rotate.hidden = (tool != TOOL_SEL) || ned;
C.btn_flipv.hidden = (tool != TOOL_SEL) || ned;
Expand Down

0 comments on commit 77fdb94

Please sign in to comment.