summaryrefslogtreecommitdiffhomepage
path: root/dragon/help.rb
blob: aee60d8e27b03983c4474e67940883ff2906bdaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# coding: utf-8
# Copyright 2019 DragonRuby LLC
# MIT License
# help.rb has been released under MIT (*only this file*).

module GTK
  class Help
    def self.primitive_contract primitive_name
      if primitive_name == :label
        label_contract
      elsif primitive_name == :solid
        solid_border_contract
      elsif primitive_name == :border
        solid_border_contract
      elsif primitive_name == :sprite
        sprite_contract
      else
        help_text = "No contract found for primitive #{primitive_name}. The supported primitives are :label, :solid, :border, :sprite."
      end
    end

    def self.label_contract
      <<-S
* :label (if :primitive_marker returns :label)
** :x, :y, :text
** :size_enum
default: 0
negative value means smaller text
positive value means larger text
** :alignment_enum default: 0
default: 0
0: left aligned, 1: center aligned, 2: right aligned
** :r, :g, :b, :a
default: 0's for rgb and 255 for a
** :font
default nil
path to ttf file
S
    end

    def self.solid_border_contract
      <<-S
* :solid, :border (if :primitive_marker returns :solid or :border)
** :x, :y, :w, :h, :r, :g, :b, :a
S
    end

    def self.label_contract
      <<-S
* :line (if :primitive_marker returns :line)
** :x, :y, :x2, :y2, :r, :g, :b, :a
S
    end

    def self.sprite_contract
      <<-S
* :sprite (if :primitive_marker returns :sprite)
** :x, :y, :w, :h
** :angle, :angle_anchor_x, :angle_anchor_y
default for angle: 0 (0 to 360 degress)
default for angle_anchor_(x|y): 0 (decimal value between 0 and 1.0, 0.5 means center)
** :r, :g, :b, :a
** :tile_x, :tile_y
default: 0, x, y offset for sprite to crop at
** :tile_w, :tile_h
default: -1, width and height of crop (-1 means full width and height)
** :flip_horizontally, :flip_vertically
default: falsey value
S
    end
  end
end