Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Latest commit

 

History

134 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MajSimai

MajSimai is an interpreter for Simai, written in C#.

Features

Metadata

  • Basic metadata fields
  • Comments ||Hello world!
  • Custom simai commands with '=' as separator &commandPrefix=value

Chart

  • BPM declaration (float)
  • Beats declaration
    • Common {int}
    • Absolute time {#float}
  • Tap 1
    • Break flag 1b
    • EX flag 1x
    • Mine flag 1m
    • Force star flag 1$
      • Fake rotation 1$$
  • Hold 1h[duration]
    • Short form 1h
    • Break flag 1hb
    • Mine flag 1bm
    • Duration format:
      • Common [division:beats]
      • With absolute time [#time]
      • With custom BPM [bpm#division:beats]
  • Slide x-y[duration]
    • Same head 1-3[duration]*-7[duration]
    • Break flag
      • 1-3[duration]b
      • 1-3b[duration]
    • Mine flag
      • 1-3[duration]m
      • 1-3m[duration]
    • Conn slide
      • 1-3-5-7[duration]
      • 1-3[duration]-5[duration]-7[duration]
    • No head slide:
      • 1?-3[duration]
      • 1!-3[duration]
    • Tap head slide: 1@-3[duration]
    • Duration format:
      • Common [division:beats]
      • With custom BPM [bpm#division:beats]
      • With custom BPM and absolute slide length [bpm#time]
      • With absolute slide start time and common slide length [time##division:beats]
      • With absolute slide start time and absolute slide length [time##time]
      • With absolute slide start time and custom BPM length [time##bpm#division:beats]
  • Touch B1
    • Hanabi flag B1f
    • Break flag B1b
    • Mine flag B1m
    • Ex flag B1x
  • Touch hold B1h[duration]
    • Short form B1h
    • Hanabi flag B1hf[duration]
    • Break flag B1hb[duration]
    • Mine flag B1hm[duration]
    • Ex flag B1hx[duration]
    • Duration format:
      • Common [division:beats]
      • With absolute time [#time]
      • With custom BPM [bpm#division:beats]
  • Each note note/note
    • Fake each 1`2`3`4,
  • EOF flag E

Getting Started

To use MajSimai in your own project, you will need to add a reference to the MajSimai library in your solution.

// Specify the chart file
var filePath = "/path/to/your/chart.txt";
using var fileStream = File.OpenRead(filePath);

// Parse into SimaiFile
var simaiFile = await SimaiParser.ParseAsync(fileStream);
// With special encoding
simaiFile = await SimaiParser.ParseAsync(fileStream, Encoding.ASCII);

// Or parse only metadata
var simaiMetadata = await SimaiParser.ParseMetadataAsync(fileStream);
// With special encoding
simaiMetadata = await SimaiParser.ParseMetadataAsync(fileStream, Encoding.ASCII);


// Or parse from the chart text you provide
var fumen = "(197){8}1,1,1,1,1,1,1,1,2b,3h,4-1[8:1],";
var simaiChart = await SimaiParser.ParseChartAsync(fumen);

Build

If you want to compile MajSimai yourself, please make sure that dotnet is installed on your computer.

The target frameworks available for MajSimai are as follows:

  • netstandard2.1
  • net5.0
  • net6.0
  • net7.0
  • net8.0
  • net9.0

Then, use the following method to compile it:

git clone https://github.com/LingFeng-bbben/MajSimai.git

cd MajSimai

dotnet restore

# Feel free to change the target framework
# If you want to generate nuget package, please remove /p:GeneratePackageOnBuild=false
dotnet publish -c release /p:PublishAot=false /p:GeneratePackageOnBuild=false -f netstandard2.1

MajSimai is AOT and Trim compatible.

If you want to compile native library, you need to specify the use of AOT.

dotnet publish -c release /p:PublishAot=true -f net9.0 -r linux-x64

In the native library, MajSimai will export functions:

  • MajSimai!MajSimai_Parse
  • MajSimai!MajSimai_Free
  • MajSimai!MajSimai_FreeHGlobal

You can use these exported functions in C++:

struct MajSimaiParseResult
{
    int32_t code = -1;
    int32_t errorAtLine = -1;
    int32_t errorAtColumn = -1;
    int32_t errorMsgLen = 0;
    int32_t errorContentLen = 0;

    void* simaiFile = NULL;
    char* errorMsgAnsi = NULL;
    char* errorContentAnsi = NULL;
};

extern "C" void __cdecl MajSimai_Parse(char*, int32_t, void*);
extern "C" bool __cdecl MajSimai_Free(MajSimaiParseResult*);
extern "C" bool __cdecl MajSimai_FreeHGlobal(void*);

int main()
{
    const string FUMEN = R"(&title=Test
&artist=NULL
&first=0
&des=1
&lv_5=114514
&inote_5=
(197){8}1,2,3,4,5,6,7,8,)";
    MajSimaiParseResult result = MajSimaiParseResult();
    MajSimai_Parse(FUMEN.data(), FUMEN.length(), &result);
    MajSimai_Free(&result);
}

About

A CSharp parser for Simai rhythm game charts

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages