Kaynağa Gözat

Added new functions

SetWindowTitle()
GetExtension()
raysan5 8 yıl önce
ebeveyn
işleme
f3f6d3fd8e
2 değiştirilmiş dosya ile 20 ekleme ve 0 silme
  1. 18 0
      src/core.c
  2. 2 0
      src/raylib.h

+ 18 - 0
src/core.c

@@ -659,6 +659,14 @@ void SetWindowIcon(Image image)
 #endif
 }
 
+// Set title for window (only PLATFORM_DESKTOP)
+void SetWindowTitle(const char *title)
+{
+#if defined(PLATFORM_DESKTOP)
+    glfwSetWindowTitle(window, title);
+#endif
+}
+
 // Set window position on screen (windowed mode)
 void SetWindowPosition(int x, int y)
 {
@@ -1152,6 +1160,16 @@ bool IsFileExtension(const char *fileName, const char *ext)
     return result;
 }
 
+// Get the extension for a filename
+const char *GetExtension(const char *fileName)
+{
+    const char *dot = strrchr(fileName, '.');
+    
+    if (!dot || dot == fileName) return "";
+    
+    return (dot + 1);
+}
+
 // Get directory for a given fileName (with path)
 const char *GetDirectoryPath(const char *fileName)
 {

+ 2 - 0
src/raylib.h

@@ -701,6 +701,7 @@ RLAPI bool WindowShouldClose(void);                               // Check if KE
 RLAPI bool IsWindowMinimized(void);                               // Check if window has been minimized (or lost focus)
 RLAPI void ToggleFullscreen(void);                                // Toggle fullscreen mode (only PLATFORM_DESKTOP)
 RLAPI void SetWindowIcon(Image image);                            // Set icon for window (only PLATFORM_DESKTOP)
+RLAPI void SetWindowTitle(const char *title);                     // Set title for window (only PLATFORM_DESKTOP)
 RLAPI void SetWindowPosition(int x, int y);                       // Set window position on screen (only PLATFORM_DESKTOP)
 RLAPI void SetWindowMonitor(int monitor);                         // Set monitor for the current window (fullscreen mode)
 RLAPI void SetWindowMinSize(int width, int height);               // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
@@ -759,6 +760,7 @@ RLAPI int GetRandomValue(int min, int max);                       // Returns a r
 
 // Files management functions
 RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
+RLAPI const char *GetExtension(const char *fileName);             // Get file extension
 RLAPI const char *GetDirectoryPath(const char *fileName);         // Get directory for a given fileName (with path)
 RLAPI const char *GetWorkingDirectory(void);                      // Get current working directory
 RLAPI bool ChangeDirectory(const char *dir);                      // Change working directory, returns true if success