1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-21 16:13:55 +00:00

Added documentation for bars, fixes in other docs

This commit is contained in:
Acamaeda 2020-10-12 23:28:02 -04:00
parent fde714d73f
commit 95e1fc2ff0
10 changed files with 54 additions and 15 deletions

39
docs/bars.md Normal file
View file

@ -0,0 +1,39 @@
# Buyables
Bars let you display information in a more direct way. It can be a progress bar, health bar, capacity gague, or anything else.
Bars are defined like other Big Features:
```js
bars: {
bigBar: {
display() {return "Blah"},
etc
}
etc
}
```
Features:
- direction: UP, DOWN, LEFT, or RIGHT (not Strings). Determines the direction that the bar is filled as it progresses.
RIGHT means from left to right.
- width, height: The size in pixels of the bar, but as Numbers (no "px" at the end)
- progress(): A function that returns the portion of the bar that is filled, from "empty" at 0 to "full" at 1.
(Nothing bad happens if the value goes out of these bounds, and it can be a number or Decimal).
- display(): **optional**, A function that returns text to be displayed on top of the bar, can use HTML.
- unlocked(): **optional**, A function returning a bool to determine if the buyable is visible or not. Default is unlocked.
- baseStyle, fillStyle, borderStyle, textStyle: **Optional**, Apply CSS to the unfilled portion, filled portion, border, and
display text on the bar, in the form of an object where the keys are CSS attributes, and the values are the
values for those attributes (both as strings).
- layer: **Assigned automagically**. It's the same value as the name of this layer, so you can do player[this.layer].points or similar
- id: **Assigned automagically**. It's the "key" which the bar was stored under, for convenient access.
The bar in the example's id is "bigBar".

View file

@ -8,7 +8,6 @@ This is a very minimal layer with minimal features. Most things will require add
startData() { return { // startData is a function that returns default data for a layer.
unlocked: false, // You can add more variables here to add them to your layer.
points: new Decimal(0), // "points" is the internal name for the main resource of the layer.
// If you add non-standard Decimal variables, look at convertToDecimal
}},
color: "#FE0102", // The color for this layer, which affects many elements

View file

@ -17,7 +17,7 @@ Buyables should be formatted like this:
Having this function makes a respec button appear
respecText: **optional**, text that appears on the respec button
11: {
display:() => "Blah",
display() {return "Blah"},
etc
}
etc

View file

@ -15,7 +15,7 @@ Challenges are stored in the following format:
rows: # of rows
cols: # of columns
11: {
name:() => "Ouch",
name: "Ouch",
etc
}
etc

View file

@ -20,7 +20,7 @@ Clickables should be formatted like this:
// pressing it will call the function.
masterButtonText: "Press me!" // **optional** text to display on the Master Button
11: {
desc:() => "Blah",
display() {return "Blah"},
etc
}
etc

View file

@ -5,7 +5,7 @@ Milestones should be formatted like this:
```js
milestones: {
0: {
requirementDesc:() => "123 waffles",
requirementDesc: "123 waffles",
}
etc
}

View file

@ -15,7 +15,7 @@ Hint: Basic point gain is calculated in game.js's "getPointGain".
rows: # of rows
cols: # of columns
11: {
desc:() => "Blah",
desc: "Blah",
more features
}
etc

View file

@ -91,12 +91,11 @@ function updateLayers(){
if (layers[layer].bars){
layers[layer].bars.layer = layer
for (thing in layers[layer].bars){
if (!isNaN(thing)){
layers[layer].bars[thing].id = thing
layers[layer].bars[thing].layer = layer
if (layers[layer].bars[thing].unlocked === undefined)
layers[layer].bars[thing].unlocked = true
}
layers[layer].bars[thing].id = thing
layers[layer].bars[thing].layer = layer
if (layers[layer].bars[thing].unlocked === undefined)
layers[layer].bars[thing].unlocked = true
}
}

View file

@ -305,7 +305,7 @@ addLayer("c", {
["blank", ['0', '50px']], ["bar", "flatBoi"]
]],
]],
"blank", ["display-text", "It's because bars! So funny! Ha ha!"],
"blank", ["display-text", "It's jail because \"bars\"! So funny! Ha ha!"],
],
},
illuminati: {

View file

@ -107,6 +107,8 @@ function constructBarStyles(layer){
let bar = tmp[layer].bars[id]
if (bar.progress instanceof Decimal)
bar.progress = bar.progress.toNumber()
bar.progress = Math.min(Math.max(bar.progress, 0), 1)
bar.dims = {'width': bar.width + "px", 'height': bar.height + "px"}
let dir = bar.direction
bar.fillDims = {'width': bar.width + "px", 'height': bar.height + "px"}
@ -115,12 +117,12 @@ function constructBarStyles(layer){
bar.fillDims[DIR_MARGINS[dir]] = "0px"
if (dir == UP || dir == DOWN)
{
bar.fillDims.height = bar.height * Math.min(bar.progress, 1) + "px"
bar.fillDims.height = bar.height * bar.progress + "px"
if (dir == UP) bar.fillDims['margin-top'] = bar.height * (1 - Math.min(bar.progress, 1)) + "px"
}
else
{
bar.fillDims.width = bar.width * Math.min(bar.progress, 1) + "px"
bar.fillDims.width = bar.width * bar.progress + "px"
if (dir == LEFT) bar.fillDims['margin-left'] = bar.width * (1 - Math.min(bar.progress, 1)) + "px"
}
}