Skip to content

Commit

Permalink
Update with config details and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sysl-dev committed Dec 3, 2020
1 parent af7eddc commit 9dde449
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 10 deletions.
Binary file added example/example_15.love
Binary file not shown.
2 changes: 1 addition & 1 deletion example/library/slog-text.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local m = {
debug = true,
debug = false,
_NAME = 'SYSL-Text',
_VERSION = '1.5',
_DESCRIPTION = 'Fancy Text System',
Expand Down
135 changes: 131 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SLog-Text
**Please see the main.lua for samples, please review the library for all the possible tags.**
**Please see the "main.lua" for samples, please review the library for all the possible tags.**

![Quick Demo of Examples](/screenshots/ex.gif?raw=true "Quick Demo of Examples")

Expand Down Expand Up @@ -30,13 +30,140 @@ my_cool_textbox:draw(0,0)
-- in love.update(dt)
my_cool_textbox:update(dt)
```
# Tags
SLog-Text supports tags in ```[these brackets]``` and will use them to apply effects to your rendered text. SLog-Text also supports defining default styles per textbox. Please take a look at the examples below.


# Screenshots
## Tags with Screenshot Examples
![Example 1](/screenshots/1.gif?raw=true "Example of Library")
```lua
example2box = Text.new("left", { color = {1,1,1,1}, shadow_color = {0.5,0.5,1,0.4}, font = Fonts.golden_apple, character_sound = true})
example2box:send("[|•] Do you like eggs?[newline][|•] I think they are [pad=6]eggzelent![audio=sfx=laugh]", 100, false)
```
![Example 2](/screenshots/2.gif?raw=true "Example of Library")
```lua
example3box = Text.new("left", { color = {1,1,1,1}, shadow_color = {0.5,0.5,1,0.4}, font = Fonts.golden_apple, character_sound = false, print_speed = 0.02})
example3box:send("I am a very cute [color=#00ff00]green frog[/color]. Would you like to eat dinner with me? It's [rainbow][bounce]fresh[/bounce] [u]fly[/u] [shake]soup[/shake]![/rainbow]", 316, false)
```
![Example 3](/screenshots/3.png?raw=true "Example of Library")
```lua
example4box = Text.new("left", { color = {0,0,0,0.95}, shadow_color = {0.5,0.5,1,0.4}, font = Fonts.earth_illusion})
example4box:send("[dropshadow=2][b]Old Man:[/b][newline]Hello young man. How are you?", 74, true)
```
![Example 4](/screenshots/4.png?raw=true "Example of Library")
```lua
example6box = Text.new("left", { color = {0.9,0.9,0.9,0.95}, shadow_color = {0.5,0.5,1,0.4}, font = Fonts.comic_neue, character_sound = true, sound_every = 5, sound_number = 2})
example6box:send("Oh wow, you found the [bounce][rainbow]high-res[/rainbow][/bounce] text! [][icon=1][icon=2][icon=3][icon=4] [icon=5][icon=6][icon=7][icon=8] [icon=9][icon=10][icon=11][icon=12][/]", 320*4-16, true)
```
![Example 5](/screenshots/5.gif?raw=true "Example of Library")
```lua
example7box = Text.new("left", { color = {0.9,0.9,0.9,0.95}, shadow_color = {0.5,0.5,1,0.4}, font = Fonts.comic_neue_big, character_sound = true, sound_every = 3, sound_number = 3})
example7box:send("[warble=-5][textspeed=0.02][][image=witch][pad=32]There's something I have to say,[pause=0.7][] [warble=5]this witch will save the day!", 320*4-16, false)
```
![Example 6](/screenshots/6.gif?raw=true "Example of Library")
![Example 7](/screenshots/7.gif?raw=true "Example of Library")
```lua
example8box = Text.new("left", { color = {0.9,0.9,0.9,0.95}, shadow_color = {0.5,0.5,1,0.4}, font = Fonts.comic_neue_small, character_sound = true, print_speed = 0.04, sound_every = 2, sound_number = 4})
example8box:send("[function=example.bop=true]Did you hear about the [color=#FF0000]bad puns?[/color][pause=0.5] You did?![pause=0.5] That's [color=#FFFF00]great[/color][pause=0.8]! [shake]Now I don't have to tell you about them![/shake][pause=1][][function=example.bop=false][][audio=sfx=laugh]", 320-80, false)
```
![Example 7](/screenshots/7.gif?raw=true "Example of Library")
```lua
example5box = Text.new("left", { color = {0.9,0.9,0.9,0.95}, shadow_color = {0.5,0.5,1,0.4}, font = Fonts.earth_illusion, character_sound = true, sound_every = 5, sound_number = 2})
example5box:send("[dropshadow=3][function=example.ex5_textboxsize=64][textspeed=0.02]With the Power of Queens, they challenged the Snakes. Garry's mighty waves peeled apart their diamond scales. The Wizards woke[waitforinput][audio=sfx=ui] [function=example.ex5_textboxsize=example.ex5_textboxsize+16]mighty windstorms. Niza brought the deadly wine[waitforinput][audio=sfx=ui] [function=example.ex5_textboxsize=example.ex5_textboxsize+16]and cheese. [audio=sfx=ui]", 320-16, false)

```

# Tags Notes
Some tags will not work until you let the library know something about your game. I will list them all below.

## Audio
```lua
--Text.configure.audio_table(table_string)
Text.configure.audio_table("Audio")
```
This configuration item will pass along the Lua table you are using to store audio sources. It currently can search down one level from that base table.
```lua
Enables "[audio]": Starts playing an audio source.
Used like: "[audio=guy-laughing]" or "[audio=music=level1]"

Enables "[/audio]": Stops playing an audio source.
Used like: "[/audio=guy-laughing]" or "[/audio=music=level1]"
```

## Audio-Sound per character
```lua
--Text.configure.add_text_sound(sound, volume)
Text.configure.add_text_sound(Audio.text.default, 0.2)
```
This will allow you to add voices so textboxes will jabber at you as they print characters. Note that the following commands will not work until you set up this configuration.
```lua
Enables:
"[voice=#]": Set the speaking voice, 0 will turn it off.
"[warble=#]": Set the pitch varience, +/- on the voice.
"[/warble]": Stops the pitch varience.
"[soundevery=#]": How often does a sound play per character.
"[/soundevery]": Reset the sound per character.

Used like: "[voice=2][warble=3][soundevery=1]I'm talking really fast and making a lot of noise![voice=0][/warble][/soundevery]"
```

## Fonts
```lua
--Text.configure.font_table(table_string)
Text.configure.font_table("Font")
```
This configuration item will pass along the Lua table you are using to store your Font sources.
```lua
Enables "[font=Font.name]": Set the font.
Used like: "[font=Font.ComicSansMs]" or "[font=Font.default]"

Enables "[/font]": Set the font back to the textbox default.
Used like: "[/font]"
```
## Images
```lua
--Text.configure.image_table(table_string)
Text.configure.image_table("img")
```
This configuration item will pass along the Lua table you are using to store image sources. It currently can search down one level from that base table.
```lua
Enables "[image=name]": Draw an image inline with the text.
Used like: "[image=skull]" or "[image=ui=skull]
```
## Icons
```lua
--Text.configure.icon_table(table_string)
Text.configure.icon_table("Icon")
```
This configuration item will pass along the Lua table you are using to hold an icon drawing library. Note that this function assumes your library has a .draw() and .count() available. .draw() would work similar to how love.graphics.draw() works, with the source being replaced by a number. .count() would just return the number of available icons. If you would prefer to just use images, you can leave this configuration out and use the "[image]" tag.
```lua
Enables "[icon=#]": Draw an icon inline with the text.
Used like: "[icon=1]
```

## Palettes
```lua
--Text.configure.palette_table(table_string)
Text.configure.palette_table("Palettes")
```
This configuration item will pass along the Lua table you are using to hold an indexed list of palettes. You can then use this prebuilt index instead of "[color=#hexval]".
```lua
Enables "[color=#]": Changed the color of the text based on a palette list.
Used like: "[color=1]
```

## Shader Effects
```lua
--Text.configure.shader_table(table_string)
Text.configure.shader_table("Shaders")
```
This configuration item will pass along the Lua table you are using to hold shader functions you have created. These shader functions can be then applied directly to the text.
```lua
Enables "[shader=name]": Apply effects on text from a shader.
Used like: "[shader=blur]
```

## Scripting Commands
```lua
--Text.configure.function_command_enable(enable_bool)
Text.configure.function_command_enable(enable_bool)
```
This nightmare will allow you to write direct lua code into a string to execute. It's off by default. Please be careful when using.
13 changes: 8 additions & 5 deletions text.lua → slog-text.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local m = {
debug = true,
debug = false,
_NAME = 'SYSL-Text',
_VERSION = '1.5',
_DESCRIPTION = 'Fancy Text System',
Expand Down Expand Up @@ -115,7 +115,7 @@ local function convert_special_character(char)
end

--[[ Get character Width ]]-----------------------------------------------------------------------------
-- Get the width of the current character width the current font.
-- Get the width of the current character width the current font. -- L2R?
local function get_character_width(character)
return love.graphics.getFont():getWidth(character)
end
Expand Down Expand Up @@ -991,10 +991,13 @@ M.command_table = {
local _mod1 = self.command_modifer[2]
local _mod2 = self.command_modifer[3]
if image_table[_mod1] and image_table[_mod1][_mod2] then
love.graphics.draw(image_table[_mod1][_mod2], self.cursor.x, self.cursor.y)
love.graphics.draw(image_table[_mod1][_mod2], self.tx + self.cursor.x, self.ty + self.cursor.y)
self.cursor.x = self.cursor.x + image_table[_mod1][_mod2]:getWidth()
elseif image_table[_mod1] then
love.graphics.draw(image_table[_mod1], self.tx + self.cursor.x, self.ty + self.cursor.y)
self.cursor.x = self.cursor.x + image_table[_mod1]:getWidth()
else
love.graphics.draw(undefined_image, self.cursor.x, self.cursor.y)
love.graphics.draw(undefined_image, self.tx + self.cursor.x, self.ty + self.cursor.y)
self.cursor.x = self.cursor.x + undefined_image:getWidth()
end
end,
Expand Down Expand Up @@ -1273,7 +1276,7 @@ function m.new(rendering, table_settings) -- Todo, configuration at runtime.
self.default_adjust_line_height = 0
self.adjust_line_height = self.default_adjust_line_height
-- Text Sounds
self.default_character_sound = table_settings.character_sound or true
self.default_character_sound = table_settings.character_sound
self.character_sound = self.default_character_sound
self.default_sound_every = table_settings.sound_every or 2
self.sound_every = self.default_sound_every
Expand Down

0 comments on commit 9dde449

Please sign in to comment.