Mercurial > projects > mde
annotate mde/content/Services.d @ 149:1125ba603af6
Some ideas for content service menus.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 14 Mar 2009 11:05:51 +0100 |
parents | 08651e8a8c51 |
children |
rev | line source |
---|---|
61
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
1 /* LICENSE BLOCK |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
2 Part of mde: a Modular D game-oriented Engine |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
3 Copyright © 2007-2008 Diggory Hardy |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
4 |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify it under the terms |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
6 of the GNU General Public License as published by the Free Software Foundation, either |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
7 version 2 of the License, or (at your option) any later version. |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
8 |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
11 See the GNU General Public License for more details. |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
12 |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
13 You should have received a copy of the GNU General Public License |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
15 |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
16 // NOTE: This module is currently unused and untested. |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
17 // FIXME: write unittests |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
18 |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
19 /** Content services. |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
20 * |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
21 * Services act on a content, potentially modifying it. They have the form: |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
22 * --- |
149
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
23 * bool service (Content c); |
61
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
24 * --- |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
25 * where c is the content acted on, and the return value is true if the content was changed (useful |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
26 * to know whether caches need updating or not). |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
27 */ |
105
08651e8a8c51
Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
61
diff
changeset
|
28 module mde.content.Services; |
61
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
29 |
149
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
30 import mde.content.AStringContent; |
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
31 |
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
32 union ContentUnion { |
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
33 *Content ; |
61
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
34 } |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
35 |
149
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
36 bool copy (Content c) { |
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
37 // store by type |
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
38 clipboard = c; |
61
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
39 } |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
40 |
149
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
41 bool paste (StringContent c) { |
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
42 if (clipboard) |
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
43 c = clipboard.toString (0); |
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
44 } |
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
45 |
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
46 bool paste (IntContent c) { |
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
47 |
61
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
48 } |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
49 |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
50 bool link (ref ContentText c) { |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
51 if (clipboard is null) |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
52 return false; // no item on clipboard, so don't do anything |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
53 c = clipboard; |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
54 return true; |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
55 } |
7cab2af4ba21
A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
56 |
149
1125ba603af6
Some ideas for content service menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
57 ContentUnion clipboard; |