Created
September 26, 2021 15:40
-
-
Save nkrapivin/a95d76887b061e10765e66e4a8fe43f6 to your computer and use it in GitHub Desktop.
fnames to pascal case thing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See https://aka.ms/new-console-template for more information | |
var namespath = @"C:\ProgramData\GameMakerStudio2-Dev\Cache\runtimes\runtime-9.9.1.2226\fnames"; | |
var lines = File.ReadAllLines(namespath); | |
var specchars = new[] { '#', '*', '@', '&', '$', '£', '!', '%', '?', '[', '(' }; | |
Console.WriteLine("// copy and paste me into your game:"); | |
foreach (var sline in lines) | |
{ | |
var line = sline.Trim(); // foreach variable cannot be modified. | |
// struct class name | |
if (line.StartsWith('/') || line.StartsWith("??") || line.Length == 0) continue; | |
var idx = line.IndexOfAny(specchars); | |
if (idx > -1) | |
line = line.Substring(0, idx); | |
var ccline = line; | |
// cursed: | |
ccline = char.ToUpper(ccline[0]) + ccline[1..]; | |
// the rest of the line: | |
for (var i = 0; i < ccline.Length; ++i) | |
{ | |
if (ccline[i] == '_') | |
{ | |
ccline = ccline.Remove(i, 2).Insert(i, char.ToUpper(ccline[i + 1]).ToString()); | |
} | |
} | |
ccline = ccline.Replace("of", "Of"); // ????????????????? | |
Console.WriteLine($"#macro {ccline} {line}"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment