~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to tools/designer/src/designer/extra/oublietteplan.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  oublietteplan.h
 
3
 *  qthack
 
4
 *
 
5
 *  Created by Trenton Schulz on 3/24/05.
 
6
 *  Copyright 2005 Trolltech AS. All rights reserved.
 
7
 *
 
8
 */
 
9
 
 
10
#ifndef OUBLIETTELEVEL_H
 
11
#define OUBLIETTELEVEL_H
 
12
 
 
13
#include <QtCore/QtCore>
 
14
#include "tile.h"
 
15
 
 
16
class OublietteLevel
 
17
{
 
18
public:
 
19
    enum LevelFeature {
 
20
        HorizontalCorridor,
 
21
        SmallHorizontalCorridor,
 
22
        VerticalCorridor,
 
23
        SmallVerticalCorridor,
 
24
        ThreeByThreeRoom,
 
25
        FiveByFiveRoom,
 
26
        TenByTenRoom,
 
27
        TotalFeatures
 
28
    };
 
29
 
 
30
    OublietteLevel(int width = 128, int height = 96, int totalFeatures = 200);
 
31
    ~OublietteLevel();
 
32
    inline QSize size() const { return m_size; }
 
33
    inline int width() const { return size().width(); }
 
34
    inline int height() const { return size().height(); }
 
35
    inline int totalItems() const { return m_totalItems; }
 
36
    Tile tile(int x, int y) const;
 
37
    inline Tile tile(const QPoint &pos) const { return tile(pos.x(), pos.y()); }
 
38
    void updateTileFlags(int x, int y, Tile::TileFlags flags);
 
39
    inline void updateTileFlags(const QPoint &point, Tile::TileFlags flags)
 
40
    { updateTileFlags(point.x(), point.y(), flags); }
 
41
 
 
42
    void addItemToTile(int x, int y, const Item *item);
 
43
    inline void addItemToTile(const QPoint &pos, const Item *item)
 
44
    { addItemToTile(pos.x(), pos.y(), item); }
 
45
 
 
46
    void clearTileFlags(int x, int y);
 
47
    inline void clearTileFlags(const QPoint &point) { clearTileFlags(point.x(), point.y()); }
 
48
    void printOubliette() const;
 
49
    bool blockLOS(int x, int y);
 
50
    void setTile(int x, int y, Tile element);
 
51
    inline void setTile(const QPoint &pos, Tile element)
 
52
    { setTile(pos.x(), pos.y(), element); }
 
53
 
 
54
private:
 
55
    void generateOubliette();
 
56
    void dig(LevelFeature feature, const QRect &rect);
 
57
    void digRoom(const QRect &rect, Tile::TileFlags flags = Tile::Default);
 
58
    QPoint findWall() const;
 
59
    LevelFeature pickFeature() const;
 
60
    QRect boundingRect(LevelFeature feature) const;
 
61
    bool placeFeature(LevelFeature feature, const QPoint &pt);
 
62
    inline void fillRect(const QRect &r, Tile le)
 
63
    { fillRect(r.x(), r.y(), r.width(), r.height(), le); }
 
64
    void fillRect(int x, int y, int width, int height, Tile le);
 
65
    bool checkForFeatures(const QRect &rect) const;
 
66
 
 
67
private:
 
68
    QSize m_size;
 
69
    Tile *m_map;
 
70
    int m_totalFeatures;
 
71
    int m_totalItems;
 
72
    QList<QRect> m_roomList;
 
73
};
 
74
 
 
75
class OubliettePlan
 
76
{
 
77
public:
 
78
    OubliettePlan(int totalLevels = 1);
 
79
    ~OubliettePlan();
 
80
    OublietteLevel *level(int level) const;
 
81
    inline int totalLevels() const { return m_totalLevels; }
 
82
 
 
83
private:
 
84
    QVector<OublietteLevel*> m_levels;
 
85
    int m_totalLevels;
 
86
};
 
87
 
 
88
#endif // OUBLIETTELEVEL_H