Commits

Anonymous committed 566a4a5

start of color controls

  • Participants
  • Parent commits 1fb4fef

Comments (0)

Files changed (1)

File src/main/java/net/fishbulb/jcod/Console.java

  * <p/>
  * Methods not supported:
  * <ul>
+ * <li>all keyboard functions (use GDX)</li>
  * <li>initRoot (there is no static root, just create a console)</li>
  * <li>setCustomFont (use setTileSet instead)</li>
  * <li>is/setFullScreen,setWindowTitle,isWindowClosed (window control not possible)</li>
  * <li>get/setFade,getFadingColor (control the TileDisplay actor instead)</li>
- * <li>all keyboard functions (use GDX)</li>
+ * <li>setDirty (not applicable)</li>
  * <li></li>
  * </ul>
  */
     @Getter @Setter
     private BlendFunction blendFunction = null;
 
-    private Color tmpColor = new Color();
-
     private final Cell[] cells;
 
     @Getter @Setter
     private TileDisplay display;
 
+    // color controls are directly interpolated into strings which is why they aren't enums
+    public static final char COLCTRL_1 = 1;
+    public static final char COLCTRL_2 = 2;
+    public static final char COLCTRL_3 = 3;
+    public static final char COLCTRL_4 = 4;
+    public static final char COLCTRL_5 = 5;
+    public static final char COLCTRL_NUMBER = 5;
+    public static final char COLCTRL_FORE_RGB = 6;
+    public static final char COLCTRL_BACK_RGB = 7;
+    public static final char COLCTRL_STOP = 8;
+
+    private Color[] colorControlFore = new Color[COLCTRL_NUMBER];
+    private Color[] colorControlBack = new Color[COLCTRL_NUMBER];
+
+
     public Console(Tileset tileSet, int width, int height, TileDisplay display) {
         this.width = width;
         this.height = height;
         }
     }
 
+    public Color getCharBackground(int x, int y) {
+        return cellAt(x, y).bg();
+    }
+
     public void setCharBackground(int x, int y, Color col) {
         setCharBackground(x, y, col, blendFunction);
     }
 
+    public Color getCharForeground(int x, int y) {
+        return cellAt(x, y).fg();
+    }
+
     public void setCharForeground(int x, int y, Color col) {
         cellAt(x, y).fg(col);
     }
 
+    public char getChar(int x, int y) {
+        return cellAt(x, y).c();
+    }
+
     public void setChar(int x, int y, char c) {
         cellAt(x, y).c(c);
     }
         }
     }
 
+    //static void setColorControl(TCOD_colctrl_t con, const TCODColor &fore, const TCODColor &back);
+    public void setColorControl(char ctrl, Color fg, Color bg) {
+        if (ctrl < 1 || ctrl > COLCTRL_NUMBER) {
+            throw new IllegalArgumentException(
+                    String.format("Color control (%s) out of range -- must be between 1 and %s", ctrl, COLCTRL_NUMBER)
+            );
+        }
+        colorControlFore[ctrl] = fg.cpy();
+        colorControlBack[ctrl] = bg.cpy();
+    }
 
     protected class Cell {
         private char c;
 //int printRect(int x, int y, int w, int h, String fmt, ...);
 //int printRectEx(int x, int y, int w, int h, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, String fmt, ...);
 //int getHeightRect(int x, int y, int w, int h, String fmt, ...);
-//static void setColorControl(TCOD_colctrl_t con, const TCODColor &fore, const TCODColor &back);
 //void print(int x, int y, const wchar_t *fmt, ...);
 //void printEx(int x, int y, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const wchar_t *fmt, ...);
 //int printRect(int x, int y, int w, int h, const wchar_t *fmt, ...);
 //void hline(int x,int y, int l, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT);
 //void vline(int x,int y, int l, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT);
 //void printFrame(int x,int y,int w,int h, boolean clear=true, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT, String fmt=NULL, ...);
-//TCODColor getCharBackground(int x, int y) const;
-//TCODColor getCharForeground(int x, int y) const;
-//int getChar(int x, int y) const;
 //boolean loadAsc(String filename);
 //boolean loadApf(String filename);
 //boolean saveAsc(String filename) const;