Commit b51c33aecea37041201cd6df7b8cb66e6c7a2922

Authored by dg
1 parent 772e73c1

Mouse wheel works in the hotkey panel


git-svn-id: http://svn.net-core.org/repos/t-engine4@2630 51575b47-30f0-44d4-a5cc-537603b46e54
... ... @@ -140,6 +140,15 @@ end
140 140 -- This is optional, only if you need mouse support
141 141 function _M:onMouse(button, mx, my, click, on_over)
142 142 local a = self.actor
  143 +
  144 + if button == "wheelup" and click then
  145 + a:prevHotkeyPage()
  146 + return
  147 + elseif button == "wheeldown" and click then
  148 + a:nextHotkeyPage()
  149 + return
  150 + end
  151 +
143 152 mx, my = mx - self.display_x, my - self.display_y
144 153 for i, zone in pairs(self.clics) do
145 154 if mx >= zone[1] and mx < zone[1] + zone[3] and my >= zone[2] and my < zone[2] + zone[4] then
... ...
... ... @@ -26,6 +26,7 @@ function _M:init(zone, map, level, spots)
26 26 Random.init(self, zone, map, level, spots)
27 27 local data = level.data.generator.actor
28 28 self.on_spot_chance = data.on_spot_chance or 70
  29 + self.spot_radius = data.spot_radius or 5
29 30 self.spot_filters = data.spot_filters or {}
30 31
31 32 -- Pick a number of spots
... ... @@ -41,7 +42,7 @@ function _M:getSpawnSpot(m)
41 42 if rng.percent(self.on_spot_chance) then
42 43 local spot = rng.table(self.spots)
43 44 if not spot then return end
44   - local _, _, gs = util.findFreeGrid(spot.x, spot.y, 5, "block_move", {[Map.ACTOR]=true})
  45 + local _, _, gs = util.findFreeGrid(spot.x, spot.y, self.spot_radius, "block_move", {[Map.ACTOR]=true})
45 46 local tries = 0
46 47 local g = rng.table(gs)
47 48 local x, y = g[1], g[2]
... ...
... ... @@ -34,6 +34,7 @@ function _M:init(zone, map, level, data)
34 34 self.hurst = data.hurst or nil
35 35 self.lacunarity = data.lacunarity or nil
36 36 self.octave = data.octave or 4
  37 + self.nb_spots = data.nb_spots or 10
37 38 self.do_ponds = data.do_ponds
38 39 if self.do_ponds then
39 40 self.do_ponds.zoom = self.do_ponds.zoom or 5
... ... @@ -138,6 +139,7 @@ function _M:generate(lev, old_lev)
138 139 end end
139 140
140 141 -- make the noise
  142 + local possible_spots = {}
141 143 local noise = core.noise.new(2, self.hurst, self.lacunarity)
142 144 for i = 1, self.map.w do
143 145 for j = 1, self.map.h do
... ... @@ -146,6 +148,7 @@ function _M:generate(lev, old_lev)
146 148 self.map(i-1, j-1, Map.TERRAIN, self:resolve("wall"))
147 149 else
148 150 self.map(i-1, j-1, Map.TERRAIN, self:resolve("floor"))
  151 + if v >= self.sqrt_percent then possible_spots[#possible_spots+1] = {x=i-1, y=j-1, type="clearing", subtype="clearing"} end
149 152 end
150 153 end
151 154 end
... ... @@ -153,6 +156,12 @@ function _M:generate(lev, old_lev)
153 156 local spots = {}
154 157 self.spots = spots
155 158
  159 + -- Add some spots
  160 + for i = 1, self.nb_spots do
  161 + local s = rng.tableRemove(possible_spots)
  162 + if s then self.spots[#self.spots+1] = s end
  163 + end
  164 +
156 165 if self.do_ponds then
157 166 for i = 1, rng.range(self.do_ponds.nb[1], self.do_ponds.nb[2]) do
158 167 self:addPond(rng.range(self.do_ponds.size.w, self.map.w - self.do_ponds.size.w), rng.range(self.do_ponds.size.h, self.map.h - self.do_ponds.size.h), spots)
... ...
... ... @@ -18,24 +18,6 @@
18 18 -- darkgod@te4.org
19 19
20 20 newEntity{
21   - define_as = "GENERAL_STORE",
22   - name = "general store",
23   - display = '1', color=colors.LIGHT_UMBER,
24   - store = {
25   - purse = 10,
26   - restock_after = 1000,
27   - empty_before_restock = true,
28   - min_fill = 40,
29   - max_fill = 60,
30   - filters = {
31   --- {type="scroll", id=true},
32   - },
33   --- fixed = {
34   --- },
35   - },
36   -}
37   -
38   -newEntity{
39 21 define_as = "ARMOR",
40 22 name = "armour smith",
41 23 display = '2', color=colors.UMBER,
... ...
... ... @@ -46,12 +46,12 @@ return {
46 46 class = "engine.generator.actor.OnSpots",
47 47 nb_npc = {20, 30},
48 48 filters = { {max_ood=2}, },
49   - nb_spots = 2, on_spot_chance = 50,
  49 + nb_spots = 2, on_spot_chance = 35,
50 50 },
51 51 object = {
52 52 class = "engine.generator.object.OnSpots",
53 53 nb_object = {6, 9},
54   - nb_spots = 2, on_spot_chance = 70,
  54 + nb_spots = 2, on_spot_chance = 80,
55 55 },
56 56 trap = {
57 57 class = "engine.generator.trap.Random",
... ...
... ... @@ -52,14 +52,16 @@ return {
52 52 lite_room_chance = 100,
53 53 },
54 54 actor = {
55   - class = "engine.generator.actor.Random",
  55 + class = "engine.generator.actor.OnSpots",
56 56 nb_npc = {20, 30},
57 57 filters = { {max_ood=2}, },
  58 + nb_spots = 2, on_spot_chance = 35,
58 59 guardian = "TROLL_BILL",
59 60 },
60 61 object = {
61   - class = "engine.generator.object.Random",
  62 + class = "engine.generator.object.OnSpots",
62 63 nb_object = {6, 9},
  64 + nb_spots = 2, on_spot_chance = 80,
63 65 },
64 66 trap = {
65 67 class = "engine.generator.trap.Random",
... ...