Skip to content

Commit

Permalink
Merge pull request #18 from SonolusHaniwa/develop
Browse files Browse the repository at this point in the history
Preview mode
  • Loading branch information
LittleYang0531 authored Jan 14, 2024
2 parents 4398767 + 7e52446 commit 5e91933
Show file tree
Hide file tree
Showing 33 changed files with 695 additions and 198 deletions.
11 changes: 8 additions & 3 deletions blocks/Archetype.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,21 @@ class Archetype {
class Archetype {
public:

string name = "Default Archtype";
static const bool disableGlobalPreprocess = false;
static constexpr const char* name = "Default Archtype";

int preprocessOrder = 0;
SonolusApi preprocess() {
return { Return(0) };
FUNCBEGIN
Return(0);
return VOID;
}

int renderOrder = 0;
SonolusApi render() {
return { Return(0) };
FUNCBEGIN
Return(0);
return VOID;
}

vector<pair<string, int> > data;
Expand Down
1 change: 1 addition & 0 deletions blocks/Variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ FuncNode mergeNodeContainer() {
if (addBlockCounter.top()) blockCounter.pop();
else blockCounter.top() -= 1;
addBlockCounter.pop();
if (c.size() == 0) throwError("Your Sonolus will boom if I accept your empty function.");
FuncNode res = FuncNode(RuntimeFunction.Block, {
c.size() == 1 ? c[0] : FuncNode(RuntimeFunction.Execute, c)
}); return res;
Expand Down
15 changes: 9 additions & 6 deletions convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,15 @@ string fromSUS(string text) {
auto tmp3 = explode(".", type.c_str());
if (tmp3.size() != 2)
throw runtime_error("Invalid Split Line Parameter: " + exp[i]);
switch(tmp2[1].size()) {
case 0: tmp2[1] = "0000"; break;
case 1: tmp2[1] = "000" + tmp2[1]; break;
case 2: tmp2[1] = "00" + tmp2[1]; break;
case 3: tmp2[1] = "0" + tmp2[1]; break;
} exp[i] = tmp2[0] + "'" + tmp2[1] + ":" + tmp3[0] + "." + tmp3[1];
// switch(tmp2[1].size()) {
// case 0: tmp2[1] = "0000"; break;
// case 1: tmp2[1] = "000" + tmp2[1]; break;
// case 2: tmp2[1] = "00" + tmp2[1]; break;
// case 3: tmp2[1] = "0" + tmp2[1]; break;
// }
while (tmp2[1].size() < 4) tmp2[1] = '0' + tmp2[1];
while (tmp3[1].size() < 5) tmp3[1] += '0'; // upd: 解决部分 Ched 保存 HiSpeed 不会保留五位小数的问题 2024/01/13
exp[i] = tmp2[0] + "'" + tmp2[1] + ":" + tmp3[0] + "." + tmp3[1];
}
sort(exp.begin(), exp.end());
for (auto i = 0; i < exp.size(); i++) {
Expand Down
Binary file modified dist/EngineData
Binary file not shown.
Binary file modified dist/EnginePreviewData
Binary file not shown.
Binary file modified dist/EngineWatchData
Binary file not shown.
60 changes: 43 additions & 17 deletions engine/constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@ double defaultAppearTime = 7.4 / 5.0; // note 默认出现时间
double minSFXDistance = 0.02; // 最小音效时间
double judgelineMarginBottom = 0.25; // 判定线距离底部距离
double judgelineHeight = 85.0 / 640.0; // 判定线高度
double noteHeight = 85.0 / 640.0; // note 高度
double judglineMoveLength = 0.01; // judgline 微调距离
double noteMoveLength = 0.02; // note 微调距离
double splitLineLength = 0.01; // 分裂线宽度
double arrowWidth = 80.0 / 640.0; // 箭头宽度
double arrowHeight = 240.0 / 640.0; // 箭头高度
double arrowPercent = 1.6; // 箭头所占比例
double arrowSpeed = 20; // 箭头速率常数
double tickWidth = 168.0 / 640.0; // tick 宽度
double tickHeight = 112.0 / 640.0; // tick 高度
double syncLineHeight = 5.0 / 640.0; // 同步线高度
double splitLineAnimationStart = 0.75; // 分裂线起始动画长度, basic: 0.7595
double splitLineAnimationEnd = 0.20; // 分裂线结束动画长度, basic: 0.7595
double effectLinearHeight = 280.0 / 640.0; // 特效高度
Expand All @@ -33,17 +27,30 @@ double judgeMissRatio = 177.0 / 76.0; // 判定文字 Miss 比例
double judgeAutoRatio = 216.0 / 76.0; // 判定文字 Auto 比例
double judgeTextHeight = 0.15; // 判定文字高度
double judgeTextDuration = 0.2; // 判定文字动画时长
double stageWidth = 0.7; // 单个舞台宽度
double stageHeight = 2.0; // 单个舞台高度
double stageFullWidth = stageWidth + 0.3; // 单个舞台占有宽度
double stageTimelineWidth = stageWidth + 0.2; // 时间线宽度
double stageTimeLength = 2.0; // 单个舞台容纳时间
double adjustDistance = 0.002; // 按键微调距离
double noteCountDistance = 10; // 按键计数长度
#if play || watch
double noteHeight = 85.0 / 640.0; // note 高度
double tickWidth = 168.0 / 640.0; // tick 宽度
double tickHeight = 112.0 / 640.0; // tick 高度
double arrowWidth = 80.0 / 640.0; // 箭头宽度
double arrowHeight = 240.0 / 640.0; // 箭头高度
double syncLineHeight = 5.0 / 640.0; // 同步线高度
#elif preview
double noteHeight = 0.04; // 按键高度
double tickWidth = 0.03; // tick 宽度
double tickHeight = 0.045; // tick 高度
double arrowWidth = 0.03; // 箭头宽度
double arrowHeight = 0.06; // 箭头高度
double syncLineHeight = 0.003; // 同步线高度
#endif

#ifdef play
let mirror = LevelOption.get(Options.Mirror);
let speed = LevelOption.get(Options.NoteSpeed);
let hidden = LevelOption.get(Options.Hidden);
let splitRandom = LevelOption.get(Options.SplitRandom);
let splitLine = LevelOption.get(Options.SplitLine);
let syncLine = LevelOption.get(Options.SyncLine);
let lockAspectRatio = LevelOption.get(Options.LockAspectRatio);
let extraWidth = LevelOption.get(Options.ExtraWidth);
#elif watch
#if play || watch
let mirror = LevelOption.get(Options.Mirror);
let speed = LevelOption.get(Options.NoteSpeed);
let hidden = LevelOption.get(Options.Hidden);
Expand All @@ -52,8 +59,11 @@ let splitLine = LevelOption.get(Options.SplitLine);
let syncLine = LevelOption.get(Options.SyncLine);
let lockAspectRatio = LevelOption.get(Options.LockAspectRatio);
let extraWidth = LevelOption.get(Options.ExtraWidth);
#elif preview
let mirror, speed, hidden, splitRandom, splitLine, syncLine, lockAspectRatio, extraWidth;
#endif

#if play || watch
class stage {
public:

Expand All @@ -68,6 +78,13 @@ class stage {
Variable<EntityMemoryId> t = h / 2;
Variable<EntityMemoryId> b = -1 * h / 2;
}stage;
#elif preview
class stage {
public:

let w, h, l, r, t, b;
}stage;
#endif

class judgline {
public:
Expand Down Expand Up @@ -121,6 +138,15 @@ class score {
let good = 0.5;
}score;

#if play || watch
Variable<LevelMemoryId> currentJudge;
Variable<LevelMemoryId> currentJudgeStartTime;
Array<LevelMemoryId, var> splitLineMemory(16);
Array<LevelMemoryId, let> splitLineMemory(16);
let duration, noteCount, noteId;
#elif preview
Variable<PreviewDataId> duration; // 谱面时长
Variable<PreviewDataId> noteCount; // note 数量
Variable<EntitySharedMemoryId> noteId; // note 编号
Array<TemporaryMemoryId, let> splitLineMemory(16);
let currentJudge, currentJudgeStartTime;
#endif
35 changes: 16 additions & 19 deletions engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,22 @@ using namespace watchData;
#include"tutorial/navigate.cpp"
#include"tutorial/update.cpp"
#elif preview
#include"skins.cpp"
#include"preview/constants.cpp"
#include"preview/utils.cpp"
#include"getSplitLine.cpp"
#include"preview/archetype/Initialization.cpp"
#include"preview/archetype/Stage.cpp"
#include"preview/archetype/NormalNote.cpp"
#include"preview/archetype/CriticalNote.cpp"
#include"preview/archetype/FlickNote.cpp"
#include"preview/archetype/HoldStart.cpp"
#include"preview/archetype/HoldEighth.cpp"
#include"preview/archetype/CriticalHoldStart.cpp"
#include"preview/archetype/ScratchHoldStart.cpp"
#include"preview/archetype/CriticalScratchHoldStart.cpp"
#include"preview/archetype/HoldEnd.cpp"
#include"preview/archetype/ScratchHoldEnd.cpp"
#include"preview/archetype/Sound.cpp"
#include"preview/archetype/SyncLine.cpp"
#include"preview/archetype/SplitLine.cpp"
#include"preview/Initialization.cpp"
#include"preview/Stage.cpp"
#include"preview/flatNotes/FlatNote.cpp"
#include"preview/flatNotes/NormalNote.cpp"
#include"preview/flatNotes/CriticalNote.cpp"
#include"preview/flatNotes/HoldStart.cpp"
#include"preview/flatNotes/CriticalHoldStart.cpp"
#include"preview/flatNotes/ScratchHoldStart.cpp"
#include"preview/flatNotes/CriticalScratchHoldStart.cpp"
#include"preview/FlickNote.cpp"
#include"preview/holdNotes/HoldEighth.cpp"
#include"preview/holdNotes/HoldEnd.cpp"
#include"preview/holdNotes/ScratchHoldEnd.cpp"
#include"preview/holdNotes/Sound.cpp"
#include"preview/SyncLine.cpp"
#include"preview/SplitLine.cpp"
#elif watch
#include"watch/updateSpawn.cpp"
#include"watch/Initialization.cpp"
Expand Down
1 change: 0 additions & 1 deletion engine/play/Initialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ class Initialization: public Archetype {

static constexpr const char* name = "Sirius Initialization";
bool input = false;
vector<pair<string, int> > data = {};

SonolusApi preprocess() {
FUNCBEGIN
Expand Down
27 changes: 27 additions & 0 deletions engine/preview/FlickNote.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class FlickNote : public Archetype {
public:

static constexpr const char* name = "Sirius Flick Note";

defineEntityData(beat);
defineEntityData(lane);
defineEntityData(laneLength);
Variable<EntitySharedMemoryId> enLane;

SonolusApi preprocess() {
FUNCBEGIN
duration = Max(duration.get(), beat);
noteCount = noteCount + 1;
noteId = noteCount.get();
enLane = lane + laneLength - 1;
return VOID;
}

SonolusApi render() {
FUNCBEGIN
IF (noteId % noteCountDistance == 0) { drawNoteCount(beat, noteId); } FI;
drawPreviewNormalNote(Sprites.ScratchNote, beat, lane, enLane);
drawPreviewArrow(beat, lane, enLane);
return VOID;
}
};
23 changes: 23 additions & 0 deletions engine/preview/Initialization.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Initialization: public Archetype {
public:

static constexpr const char* name = "Sirius Initialization";

SonolusApi preprocess() {
FUNCBEGIN
duration = 0; noteCount = 0;

let menuWidth = 0.15 * ui.menuConfiguration.scale;
let menuHeight = 0.15 * ui.menuConfiguration.scale;
let menuX = screen.r - interfaceGap;
let menuY = screen.t - interfaceGap;
ui.menu.set(menuX, menuY, 1, 1, menuWidth, menuHeight, 0, ui.menuConfiguration.alpha, true);

let progressWidth = screen.w - interfaceGap * 2;
let progressHeight = 0.15 * ui.progressConfiguration.scale;
let progressX = screen.l + interfaceGap;
let progressY = screen.b + interfaceGap;
ui.progress.set(progressX, progressY, 0, 0, progressWidth, progressHeight, 0, ui.progressConfiguration.alpha, true);
return VOID;
}
};
25 changes: 25 additions & 0 deletions engine/preview/SplitLine.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class SplitLine: public Archetype {
public:

static constexpr const char* name = "Sirius Split Line";

defineEntityData(beat);
defineEntityData(endBeat);
defineEntityData(split);
defineEntityData(color);

SonolusApi preprocess() {
FUNCBEGIN
duration = Max(duration.get(), beat);
return VOID;
}

SonolusApi render() {
FUNCBEGIN
getSplitLine(color);
drawPreviewSplitLine(beat - splitLineAnimationStart, beat, 1, split);
drawPreviewSplitLine(beat, endBeat, 0, split);
drawPreviewSplitLine(endBeat, endBeat + splitLineAnimationEnd, 2, split);
return VOID;
}
};
20 changes: 20 additions & 0 deletions engine/preview/Stage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Stage: public Archetype {
public:

static constexpr const char* name = "Sirius Stage";
bool input = false;

int preprocessOrder = 1;
SonolusApi preprocess() {
FUNCBEGIN
canvas.set(Scroll.LeftToRight, Ceil(duration.get() / stageTimeLength) * stageFullWidth);
return VOID;
}

SonolusApi render() {
FUNCBEGIN
FOR (i, 0, Ceil(duration / stageTimeLength), 1) { drawStage(i); } DONE
FOR (i, 0, duration + 1, 1) { drawTime(i); } DONE
return VOID;
}
};
15 changes: 15 additions & 0 deletions engine/preview/SyncLine.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class SyncLine: public Archetype {
public:

static constexpr const char* name = "Sirius Sync Line";

defineEntityData(beat);
defineEntityData(left);
defineEntityData(right);

SonolusApi render() {
FUNCBEGIN
drawPreviewSyncLine(beat, left, right);
return VOID;
}
};
6 changes: 6 additions & 0 deletions engine/preview/flatNotes/CriticalHoldStart.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class SiriusCriticalHoldStart: public FlatNote {
public:
static constexpr const char* name = "Sirius Critical Hold Start";

let getSprite() { return Sprites.CriticalNote; }
};
6 changes: 6 additions & 0 deletions engine/preview/flatNotes/CriticalNote.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class CriticalNote: public FlatNote {
public:
static constexpr const char* name = "Sirius Critical Note";

let getSprite() { return Sprites.CriticalNote; }
};
6 changes: 6 additions & 0 deletions engine/preview/flatNotes/CriticalScratchHoldStart.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class SiriusCriticalScratchHoldStart: public FlatNote {
public:
static constexpr const char* name = "Sirius Critical Scratch Hold Start";

let getSprite() { return Sprites.CriticalNote; }
};
25 changes: 25 additions & 0 deletions engine/preview/flatNotes/FlatNote.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class FlatNote: public Archetype {
public:

defineEntityData(beat);
defineEntityData(lane);
defineEntityData(laneLength);
Variable<EntitySharedMemoryId> enLane;
virtual let getSprite() { return -1; }

SonolusApi preprocess() {
FUNCBEGIN
duration = Max(duration.get(), beat);
noteCount = noteCount + 1;
noteId = noteCount.get();
enLane = lane + laneLength - 1;
return VOID;
}

SonolusApi render() {
FUNCBEGIN
IF (noteId % noteCountDistance == 0) { drawNoteCount(beat, noteId); } FI;
drawPreviewNormalNote(getSprite(), beat, lane, enLane);
return VOID;
}
};
6 changes: 6 additions & 0 deletions engine/preview/flatNotes/HoldStart.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class SiriusHoldStart: public FlatNote {
public:
static constexpr const char* name = "Sirius Hold Start";

let getSprite() { return Sprites.HoldNote; }
};
6 changes: 6 additions & 0 deletions engine/preview/flatNotes/NormalNote.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class NormalNote: public FlatNote {
public:
static constexpr const char* name = "Sirius Normal Note";

let getSprite() { return Sprites.NormalNote; }
};
6 changes: 6 additions & 0 deletions engine/preview/flatNotes/ScratchHoldStart.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class SiriusScratchHoldStart: public FlatNote {
public:
static constexpr const char* name = "Sirius Scratch Hold Start";

let getSprite() { return Sprites.ScratchNote; }
};
Loading

0 comments on commit 5e91933

Please sign in to comment.