ソースを参照

added color changes

Dave Schuyler 21 年 前
コミット
8f58f48b78
1 ファイル変更11 行追加1 行削除
  1. 11 1
      direct/src/showbase/OnScreenDebug.py

+ 11 - 1
direct/src/showbase/OnScreenDebug.py

@@ -20,12 +20,22 @@ class OnScreenDebug:
         
         
         fontPath = config.GetString("on-screen-debug-font", "cmtt12")
         fontPath = config.GetString("on-screen-debug-font", "cmtt12")
         fontScale = config.GetFloat("on-screen-debug-font-scale", 0.05)
         fontScale = config.GetFloat("on-screen-debug-font-scale", 0.05)
+
+        color = {
+            "black": Vec4(0, 0, 0, 1),
+            "white": Vec4(1, 1, 1, 1),
+            }
+        fgColor = color[config.GetString("on-screen-debug-fg-color", "white")]
+        bgColor = color[config.GetString("on-screen-debug-bg-color", "black")]
+        fgColor.setW(config.GetFloat("on-screen-debug-fg-alpha", 0.85))
+        bgColor.setW(config.GetFloat("on-screen-debug-bg-alpha", 0.85))
+        
         font = loader.loadFont(fontPath)
         font = loader.loadFont(fontPath)
         if not font.isValid():
         if not font.isValid():
             print "failed to load OnScreenDebug font", fontPath
             print "failed to load OnScreenDebug font", fontPath
             font = TextNode.getDefaultFont()
             font = TextNode.getDefaultFont()
         self.onScreenText = OnscreenText.OnscreenText(
         self.onScreenText = OnscreenText.OnscreenText(
-                pos = (-1.0, 0.9), bg=Vec4(1,1,1,0.85),
+                pos = (-1.0, 0.9), fg=fgColor, bg=bgColor,
                 scale = (fontScale, fontScale, 0.0), align = TextNode.ALeft,
                 scale = (fontScale, fontScale, 0.0), align = TextNode.ALeft,
                 mayChange = 1, font = font)
                 mayChange = 1, font = font)
         # Make sure readout is never lit or drawn in wireframe
         # Make sure readout is never lit or drawn in wireframe