Code Monkey home page Code Monkey logo

fibertocloth's Introduction

Fiber2Cloth

A simple library that converts Fiber’s Config Node to Cloth Config Screen in 1 line.

Requires Cloth Config 2 v0.5.2 or above

NOTE: This is still an experimental library, and there aren’t a lot of features. I will be using this library on my own mods and I will see how this goes.

Licensing

Fiber2Cloth and ClothConfig is unlicensed, no crediting is required. Fiber is licensed under Apache License 2.0. Make sure that you properly comply with their license.

Maven

Latest Version of Fiber2Cloth: image

Latest Version of ClothConfig 2: image

Latest Version of Fiber: Click Me

dependencies {
    modApi ("me.shedaniel.cloth:config-2:ABC") {
    	transitive = false
    }
    modApi ("me.shedaniel.cloth:fiber2cloth:ABC") {
        transitive = false
    }
    modApi "me.zeroeightsix:fiber:ABC"
    include "me.shedaniel.cloth:config-2:ABC"
    include "me.shedaniel.cloth:fiber2cloth:ABC"
    include "me.zeroeightsix:fiber:ABC"
}

Default Supported Types

  • Integer
  • Long
  • Float
  • Double
  • Boolean
  • String
  • Integer[]
  • Long[]
  • Float[]
  • Double[]
  • String[]

API Usage

This is the one line that will convert your config node into a cloth config screen.

Fiber2Cloth.create(screen, modid, configNode, configScreenTitleKey).setSaveRunnable(() -> {
    // Here you should serialise the node into the config file.
}).build().getScreen();

A default category will be created (name is customisable) if there is a config value without a forked parent.

Multiple layers of forking is allowed, and sub categories will be used starting from the second layer.

Using Unsupported Types

If you have an object type outside the default supported types, you can use Fiber2Cloth#registerConfigEntryFunction, it takes the class of the object type and a function that turns ConfigValue into AbstractConfigListEntry

You can see examples in Fiber2ClothImpl#initDefaultFunctionMap

Changing the default Yes / No text for boolean toggles

Declare the yes / no text in lang files with key config.{modid}.{valueName}.boolean.{true/false}, and if the key is found translated, it will automatically switch to using that instead of the default.

Example

Fiber2Cloth's example lang has config.fiber2cloth.exampleBool.boolean.true set to yo this is true, which means that config.fiber2cloth.exampleBool's Yes text is changed to yo this is true automatically.

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.