Giter Club home page Giter Club logo

cwtools-vscode's Introduction

cwtools nuget

A library for parsing, editing, and validating Paradox Interactive script files.
Supports all modern Paradox Interactive games, and targets .net standard 2.0.

Considering contributing? Start here!

Projects that use CW Tools

An interactive tech tree visualiser that uses CW Tools to parse the vanilla tech files, and extract localisation.

A mod manager that uses CW Tools for parsing and manipulating mod files.

Example usage (C#)

This is a simple example of loading an event file, modifying it, and printing the updated events.

            //Support UTF-8
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

            //Parse event file
            var parsed = CWTools.Parser.CKParser.parseEventFile("./testevent.txt");
            var eventFile = parsed.GetResult();

            //"Process" result into nicer format
            var processed = CK2Process.processEventFile(eventFile);

            //Find interesting event
            var myEvent = processed.Events.FirstOrDefault(x => x.ID == "test.1");
            
            //Add is_triggered_only = true
            var leaf = new Leaf("is_triggered_only", Value.NewBool(true));
            myEvent.AllChildren.Add(Child.NewLeafC(leaf));
            // or
            myEvent.AllChildren.Add(Leaf.Create("is_triggered_only", Value.NewBool(true)));

            //Output
            var output = processed.ToRaw;
            Console.WriteLine(CKPrinter.printKeyValueList(output, 0));

Which will take a file like

namespace = test

#One event
country_event = {
        id = test.1
    desc = "test description"
}
#Another event
country_event = {
    id = test.2
desc = "test 2 description"
}

and output a file like

namespace = test
#One event
country_event = {
        is_triggered_only = yes
        id = test.1
        desc = "test description"
         }
#Another event
country_event = {
        id = test.2
        desc = "test 2 description"
         }

cwtools-vscode's People

Contributors

herrx2000 avatar tboby avatar tbobyox avatar uristmcdorf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cwtools-vscode's Issues

i18n characters are potentially not handled correctly

In localisation files, I was trying to use some i18n characters, but it raises some error.

Note: The error occurred at the end of the input stream.
Expecting: ':'
CW001(CW001)

I was looking for misses entirely, but I could not be found.
Then, I was trying to remove all i18n characters and the error disappeared.

Next, I was loading the errored file with a stellaris game, however, it correctly works.

Massive memory spike requiring restart

Several times since the latest update something is causing cwtools to use a massive amount of memory (10 gb+) and a great deal of processor usage as well.

This last occurred when I was trying to search inside a file. I have two windows open with the extension running and files (including the same file) in each if that might help pinpoint the issue.

I had never encountered this before the last update.

Also possibly unrelated (as I also updated vscode), but I used to be able to edit the same file in multiple windows and it would share the edits across them simultaneously (I could make sure they were in sync due to the edit dot). Now it requires I save to update the changes across windows. This probably isn't related to your extension but in case it was and you might know of a fix I thought I'd bring it up.

Feature Request: Make CWTools work outside the default mod path

I would suggest making it possible for CWTools to operate from outside of the default mod folder. Using it outside currently makes CWTools unable to recognize issues. Only moving to the default location fixes this. I see it as problematic, as Paradox Launcher and Steam to a degree can mess with that location, which i find unreasonable for developing a consistent mod. So i request this to be more flexible, so corruption due to Paradox Launcher or Steam acting up cant happen.

hoi4 submod thing

If I am making a submod for a mod it shows a bunch of errors for missing ideas and gfx because submods only have files for the things that it is changing instead of copying the whole mod folder. Also the letter Y in the focus tree is an error for some reason

Event graph view

Features:

  • Generate a graph view for events in the current file
  • Generate a graph view for events referenced (or referenced by) events in the current file
  • Draw edges from events to events they trigger
  • Display the event id and event comment above each event
  • On clicking an event, go to it in code
  • On hovering over an event, show all used/set scopes
  • On pressing a button, export the graph to an image
  • On pressing a button, export the graph to json
  • Generate a graph view for the given saved json

Proposed graph return structure

type GraphDataItem = 
{
    id : string
    displayName : string option
    documentation : string option
    references : string list
    location : range option
    details : Map<string, string list> option
}

Extension does not work on Windows for CK3

I installed the extension, but it didn't work. I followed all the steps correctly.

I looked at the logs for the language server and the shortcut (Windows):
~/.vscode\extensions\tboby.cwtools-vscode-0.9.3\.cwtools\ck3\_git2_a04756

Directed to a non-existant folder:
~/.vscode\extensions\tboby.cwtools-vscode-0.9.3\.cwtools\ck3\testing

After creating an empty folder here the extension started working.

I have not tried other games.

CW241 Unexpected Node

Hi

I am working on a Mod, and I am getting a message [CW241] Unexpected Node heir_title_female in ruler [CW241]

I have checked by creating an empire in game and this is the correct name to use for Female heir's.
heir_title_female ="Princess Royal"

Any ideas? I know I can safely ignore this but wanted to check if it's something obvious.

EU4 1.30 update

Greetings tboby, thanks first of all for the tool!

I'd very much like to contribute to help getting the EU4 part update for 1.30. Concerning VSCode extension coding, I know JS from working with RN and basic shell scripting but don't know where to get started.

Do you have something I can help you with?

Suggestion: HOI4 - Add support for scoped loc

In HOI4 localization of technologies, parties and so on can be customized per tag. When that tag is known in the script itself, for example:

TAG = {
    communist > 0.1
}

Hovering over communist should give you the default name in the loc for the communist party and also the one that's defined for the tag TAG_communist.

Optionally, it'd be great if all this loc could be resolved to all the scoped locs that key can have, say, by right clicking on it.

Generating vanilla cache...

I'm following every instruction plus some more but after I select the game location it gets stuck at "Generating vanilla cache..." and it doesn't go away no matter what. I changed the directory, reinstalled cwtools, made the config manual, tried a different version, even sysmlinked the folder as "C:\CK3" thinking it could be the spaces.

I still think it's the location but I don't know why. These are some locations I used but didn't work. What am I doing wrong here? I've been trying for 5 hours and I'm gonna lose it.

  • C:\Program Files (x86)\Steam\steamapps\common\Crusader Kings III
  • C:\Program Files (x86)\Steam\steamapps\common\Crusader Kings III\
  • C:\Program Files (x86)\Steam\steamapps\common\Crusader Kings III\game
  • C:\Program Files (x86)\Steam\steamapps\common\Crusader Kings III\game\
  • C:\CK3
  • C:\CK3\
  • C:\CK3\game
  • C:\CK3\game

Hoi4 ideas not treated as symbols

Hoi4 ideas are stored like:

ideas = {
    country = {
        idea_1 = {
            ...
        }
    }
}

It only recognizes ideas as a symbol, not processing under the structure.

New DLC problems HoI4

New DLC got released for hoi4 and now all new commands aren't recognized by the extension, I hope it is fixed soon, I can't work without your extension ❤️ :trollface:
I hope I didn't miss the repo

Curated References

I'm working on understanding stellaris modding and getting into it, this extension is very useful but I was wondering if there were any way to choose a set of folders to automatically load into cwtools that way I don't have to open every single modded file I need to reference something from every time I open up my workspace. Great work and thanks a ton!

Support for CK3

CK3 was released.
Is there any way (or guide) to extend the tool so that it can support CK3?

Suggestion: Check for unused GFX

This report comes from the old magic machine for Hearts of Iron 4: Kaiserreich/HOI4-Validator#33 at the request of Zankoas on the Kaiserreich discord.

In order to add a new bit of GFX to the game (most GFX anyway), you add the file into the /gfx folder, and then list it in the respective text file in \interface, finally, you then add then it to the event/focus/idea/etc you want to change. So when you say 'unused' GFX it's a pretty vague term; does that mean that there are bits of GFX that are in the game files but not listed in \interface or that they are listed in \interface but not actually used in game anywhere? Have no idea. In addition scanning for ceratin types only can help a lot; event GFX are well over 100x the size of icon GFX; so finding unused ones there is far more important. Finally, the current scanning methord is full of false positives due to not understanding the rules different bits of GFX use.

Better scanning routes would be these:

Unlisted event GFX, when there is a file in \gfx\event_pictures not listed in \interface
Unused event GFX, when it is listed in \interface but not then used in any event in \events

Unlisted idea GFX, when there is a file in \gfx\interface\ideas not listed in \interface
Unused idea GFX, when it is listed in \interface but not then used in any event in \common\ideas

Unlisted focus GFX, when there is a file in \gfx\interface\goals not listed in \interface
Unused focus GFX, when it is listed in \interface but not then used in any event in \common\national_focus

Unused portrait (they don't need to be listed), when there is a file in \gfx\leaders not used anywhere in \events, \common\national_focus, \common\scripted_effects or \history\countries

Unused flags (they don't need to be listed), when there is a file in \gfx\flags, \gfx\flags\small or \gfx\flags\medium not named right, all three groups follow the same rules. How do you tell if it is named right? It's name must start with either a tag listed in \history\countries or a cosmetic tag listed in \events, \common\national_focus, \common\scripted_effects or \history\countries. It should finished with either nothing (as in just be 'GER' or an ideology listed in common/ideologies/00_ideologies.txt, as in 'AFG_national_populist').

Unlisted technologies (they don't need to be used), any file in \gfx\interface\technologies not listed in \interface.

Unlisted models (they don't need to be used), any file in\gfx\models not listed in \gfx\entities.

"NOR" in HoI4

Very small thing. In HoI4, NOR is now NOT, but NOR is also often used as the tag for Norway.

Code such as:
NOR = {
OR = {
has_war = no
country_exists = NOR
NOT = {
has_socialist_government = yes
}
}
}
Will pop a warning for redundancy of OR inside NOR even though NOR has been replaced by NOT in HoI4.

Random Crash on Hover

I'll update with more details as I figure out a pattern :P

I had a workspace open with my mod folder and the default Stellaris folder, if that matters at all.

This specific one was caused by hovering over 'id' in a fleet_event in horizonsignal_events.txt akx.9000, though I don't think it matters since hovering over anything right now causes an instantaneous exception.

Hover

Unhandled Exception: System.Exception: Request message with id 527131920 missing params
   at LSP.Parser.parseMessage(String jsonText)
   at [email protected](String jsonText)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.map@74.DoMoveNext(b& curr)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Collections.SeqModule.TakeWhile@1309.GenerateNext(IEnumerable`1& next)
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()
   at [email protected]()
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
[Info  - 2:07:03 AM] Connection to server got closed. Server will restart.
[Error - 2:07:03 AM] Request textDocument/hover failed.
Error: Connection got disposed.
	at Object.dispose (C:\Users\vipsp\.vscode\extensions\tboby.cwtools-vscode-0.5.32\node_modules\vscode-jsonrpc\lib\main.js:825:25)
	at Object.dispose (C:\Users\vipsp\.vscode\extensions\tboby.cwtools-vscode-0.5.32\node_modules\vscode-languageclient\lib\client.js:57:35)
	at LanguageClient.handleConnectionClosed (C:\Users\vipsp\.vscode\extensions\tboby.cwtools-vscode-0.5.32\node_modules\vscode-languageclient\lib\client.js:1967:42)
	at LanguageClient.handleConnectionClosed (C:\Users\vipsp\.vscode\extensions\tboby.cwtools-vscode-0.5.32\node_modules\vscode-languageclient\lib\main.js:126:15)
	at closeHandler (C:\Users\vipsp\.vscode\extensions\tboby.cwtools-vscode-0.5.32\node_modules\vscode-languageclient\lib\client.js:1954:18)
	at CallbackList.invoke (C:\Users\vipsp\.vscode\extensions\tboby.cwtools-vscode-0.5.32\node_modules\vscode-jsonrpc\lib\events.js:71:39)
	at Emitter.fire (C:\Users\vipsp\.vscode\extensions\tboby.cwtools-vscode-0.5.32\node_modules\vscode-jsonrpc\lib\events.js:135:36)
	at closeHandler (C:\Users\vipsp\.vscode\extensions\tboby.cwtools-vscode-0.5.32\node_modules\vscode-jsonrpc\lib\main.js:221:26)
	at CallbackList.invoke (C:\Users\vipsp\.vscode\extensions\tboby.cwtools-vscode-0.5.32\node_modules\vscode-jsonrpc\lib\events.js:71:39)
	at Emitter.fire (C:\Users\vipsp\.vscode\extensions\tboby.cwtools-vscode-0.5.32\node_modules\vscode-jsonrpc\lib\events.js:135:36)
	at StreamMessageReader.AbstractMessageReader.fireClose (C:\Users\vipsp\.vscode\extensions\tboby.cwtools-vscode-0.5.32\node_modules\vscode-jsonrpc\lib\messageReader.js:135:27)
	at Socket.<anonymous> (C:\Users\vipsp\.vscode\extensions\tboby.cwtools-vscode-0.5.32\node_modules\vscode-jsonrpc\lib\messageReader.js:188:62)
	at emitOne (events.js:121:20)
	at Socket.emit (events.js:211:7)
	at Pipe._handle.close [as _onclose] (net.js:554:12)
Listening on stdin
New configuration {settings =
  {
  "cwtools": {
    "trace": {
      "server": "off"
    },
    "localisation": {
      "languages": [
        "English"
      ]
    },
    "errors": {
      "vanilla": "false",
      "ignore": [],
      "ignorefiles": [
        "README.txt",
        "credits.txt",
        "credits_l_simp_chinese.txt",
        "reference.txt",
        "startup_info.txt"
      ]
    },
    "experimental": "false",
    "experimental_completion": "false"
  }
};}`

Auto correction removes "hsv" before brackets

Auto correction of CWTools always remove "hsv" before brackets, makes

color = hsv {
  30
  0.44
  0.58
}

into

color = {
  30
  0.44
  0.58
}

The former syntax is legal. It shouldn't be corected.

No language mode?

I'm looking for the language mode with this extension, but I can't find it.

Wrong modifier scope warning

图片
图片
The code is from vanilla file common/traits/04_species_traits.txt, and the addon thinks it's used in a country scope?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.