ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/backend/communicator/command_parser/fx.h
Revision: 1.2
Committed: Tue Oct 19 09:45:08 2010 UTC (16 years ago) by sf-pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.1: +10 -2 lines
Log Message:
- use wchar_t for single characters (glyphs and line drawing)
- merge ncurses and ndk wrappers
- simplify colour caching

File Contents

# User Rev Content
1 sf-pippijn 1.1 #include "deliantra/data/fx.h"
2     #include "deliantra/data/glyph.h"
3    
4 sf-pippijn 1.2 static wchar_t
5     wchar (std::string const &s)
6     {
7     wchar_t wc;
8     return_val_unless (mbtowc (&wc, s.data (), s.length ()) != -1, L'?');
9     return wc;
10     }
11    
12 sf-pippijn 1.1 void
13     command_parser::on_fx (std::istream &args)
14     {
15     std::vector<data::fx> faces;
16    
17     u32 type = 0;
18     while (args.peek () != EOF)
19     {
20     u32 facenum = read_ber32 (args);
21     std::string name = read_string08 (args);
22    
23     if (facenum)
24     {
25     data::glyph glyph;
26     if (!name.empty ())
27     {
28     glyph.fg = name[0];
29     glyph.bg = name[1];
30 sf-pippijn 1.2 glyph.text = wchar (name.substr (2));
31 sf-pippijn 1.1 }
32     else
33 sf-pippijn 1.2 glyph.text = L' ';
34 sf-pippijn 1.1 data::register_glyph (facenum, glyph);
35     faces.emplace_back (data::fx { type, facenum, name });
36     }
37     else if (name.length () == 1)
38     type = name[0];
39     }
40    
41     emit fx (faces);
42     }