Git Product home page Git Product logo

hedgewars-typewriter's Introduction

Hedgewars Typewriter

Hedgewars LDoc

Typewriter Hedgewars Lua library, which wraps up text visuals in Hedgewars with typewriter animations.

Typewriter harnesses Animate Hedgewars library. Right now, the only function supported is Typewriter.AddMissionAnim. It adds ability to draw mission panel with caption, subcaption and text animated in typewriter sequence. See its action in this video:

It's not a secret that animations bring more attention than static panels. You may find it useful for embedding in your campaigns, missions and even multiplayer game styles.

I plan to add more typewriting animations of tags and other GUI with dynamic text, so stay in touch: press "Watch" here, give a star and/or fork repository! We also have discussion at Hedgewars Forums.

Installation

Take the desired release here in form of Typewriter_v*.hwp file, which is recommended for loading addon in Hedgewars. Inside the user directory find folder Data and place downloaded *.hwp there.

Demo

You might wanna try Typewriter without custom script now, so here is Typewriter_Demo_v*.hwp. Just place it near by Typewriter_v*.hwp file and open in game: Singleplayer Missions โ†’ Scenarios โ†’ Typewriter Demo.

Usage

Public functions belong to Typewriter namespace. You can place them at demand: between, before, or after other animations added with AddAnim.

Keep in mind that flow of animation is asynchronous from the code you call in. To perform actions after animation is complete, use either AddAnim or AddFunction.

AddMissionAnim

Add whole typewriter animation for mission panel.

HedgewarsScriptLoad("/Scripts/Typewriter.lua")

function onGameStart()
    Typewriter.AddMissionAnim({
        caption = "Hello World",
        subcaption = "<3",
        text = "This is just working, alright?"
    })
end

Options set is not limited to sole visuals: address to Typewriter.lua for more verbose information.

Everything's optional (including icon)

Of course, table is here to not confuse order of parameters, it can be ordered however you like. Actually, you can omit everything, because they are optional as long as you have proper globals set up. Here's the example:

Typewriter.Mission.caption = "My Super Campaign"
Typewriter.AddMissionAnim({
    text = "Your fort is in danger! | Go place some girders.",
    icon = 2
})

This way, only detail text appears animated, caption will be shown instantly as common mark between your missions (same applies to subcaption, here it's empty by default).

You also can set icon passed to ShowMission. Check out ammo types for more icons (these constants require prepended minus sign).

Customize or disable sounds

Typewriter.AddMissionAnim({
    text = "Collect box on the other side of street",
    sound_typing = false,
    sound_return = sndMineTick
})

Here we completely disabled typing sound, but also changed another sound that plays when whole animation is considered complete.

Change behavior on animations' end

Typewriter.AddMissionAnim({
    subcaption = "same day, 9:00 PM",
    text = "Suppose we have a long text here...",
    display_time_after = 5000,
    force_display_after = true
})

Usually, we forcedly display mission panel only during animations. When all text was typed, default display time is ~3000ms, and player can easily hide panel by pressing M. But if force_display_after is truthy, mission panel will be forcedly shown during display_time_after extra time.

Set delays

You would probably like to set delays globally, so here is an example:

Typewriter.Mission.delay_caption_start = 1000
Typewriter.Mission.delay_caption_char = 200
Typewriter.Mission.delay_subcaption_start = 500
Typewriter.Mission.delay_subcaption_char = 150
Typewriter.Mission.delay_text_start = 400
Typewriter.Mission.delay_text_char = 100
Typewriter.Mission.delay_return = 2000

This particular example guarantees irritatingly slower experience for a player. ๐Ÿ˜œ

However, you can find more optimal values based on your mission's setting. These are available even per one command.

Mission panel as cinematic monologue

By default, all mission panels are intended to be important to look at, so you won't miss the last one after skipping animation with SetAnimSkip. But what if you wish to use mission panel as element of monologue or for any reason hide said panel if player skips over it? That's when you set:

Typewriter.AddMissionAnim({
    text = "Yeah-yeah, don't listen to me.",
    modal = false
})

hedgewars-typewriter's People

Contributors

vintprox avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

hedgewars-typewriter's Issues

Trim spaces from both ends of line

There is no use for usual spaces dangling in the start and the end of each line (we may make an exception for other whitespaces), so they should be cut off prematurely. It will also mean that they'll receive no extra sound nor cause any delay.

Hedgewars mission panels have special syntax for doing line break with | (pipe) character, which means that in this case spaces can be trimmed around such line breaks. This suggestion doesn't account for spaces in the beginning and ending of the text though - use better judgment.

HW Animate: make cinematic lock optional

Currently, there is no way to make cinematic and inputs lock optional for playing animations with OOTB Animate library. It's hardcoded.
This prevents from displaying team name and label during their animation.
Would be nice if Animate had some global variables and function parameters saying whether following animation requires cinemalock/inputlock, in single namespace Animate as it was implemented in Typewriter.

Add whitespace delay

As of now, whitespace has a delay of any other character. There should be an option to specify special delay for whitespace characters. By default, it would be imperative to just use the same delay as set for other characters.

Whitespace handling

Currently, whitespace characters (usual space, wide space, tabs, etc.) are handled like any other. They need special treatment to make typewriter look and sound more natural.

Adopt classes

I kinda dreaded to introduce object-oriented programming on the table because of added complexity, but I see quite a few advantages with an adoption of classes:

  1. Contain settings in instances of the class, separate objects. Imagine regularMissionAnimator and specialMissionAnimator. To make these work without repurposing class, one has to retain settings for regular (more common) animation in global Typewriter table, apply some other override for special mission animation, and on top of that merge this same override with one-time override (text, icon, etc.) - and so every time. With new approach, we avoid losing more common overrides somewhere in the middle and can reuse freshly made commons for consequent animations.
  2. Split the responsibility. Imagine MissionPanelAnim and CaptionAnim. We don't want to reinstantiate a giant monolith of settings for literally some speech bubble animation that we'll use just once per game. So, it makes sense to separate speech bubble animation from mission panel and any other kind of animation, for example.
  3. Inheritance can help us give classification and share common methods for all kinds of animation.

Change typing sound for whitespace

You'd imagine that caret should just skip whitespace and go type character after it. Right now, it's treated like any other symbol, hence it's doing typing of the air. Turn off sound by default and allow to change it to something else entirely.

Skip serial whitespaces

Right now, whitespaces that come in sequence are treated as a regular character. But don't confuse this issue with sound (#9) and delay for whitespace (#10). In this scenario, we should treat whitespace and a bunch of consequent whitespaces as a single one. This means simply ignoring 2nd, 3rd, 4th and so on until another kind of character appears.

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.