;;;; Ru*** roLeplay Playground virtual tabletop ;;;; Copyright (C) 2022 Zull ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU General Public License ;;;; along with this program. If not, see . (defpackage :rulp.graphics (:use :cl :rulp.layers :rulp.geometry) (:export playground +plane+ *plane* *plane-grid* *map-info* *map-path* *entities-list* arrange-rect *window-width* *window-height* tr-write )) ;; NOTE: remove +plane+, there is no other occurrence of the parameter on the code (in-package :rulp.graphics) ;; these variables contain information for the plane and grid systems. The default ;; grid is a square grid but by changing the grid-layout function it is possible ;; to modify it (defparameter *plane* nil "the plane containing the graphics to be desplayed on the background. This is a basic layout:screen") (defparameter *plane-grid* 10 "the grid for the plane. By default the grid is square and this value contain the pixels between lines") (defparameter *entities-list* nil "the list of the entities to be displayed on the plane. these entities are global and by default not connected to the *plane* choice. To change planes and entities use the proper functions") (defparameter *renderer* nil "a variable containing the tool to render textures to screen, this is associated with the screen and created in the view file but used almost everywhere. this is a side variable and cannot be moved in a sdl enviroinment.") (defparameter *pointer* nil "this is a numeric value whose refer to the selected entity in the plane, it is used combined with input to apply the actions and with view to display a 1x1 over grid square of the entity") ;; tr stands for text-rendering (defparameter *tr-string* "abcdefghijklmnopqrstuvwxyz 0123456789-" "This string is used to generate a texture with the alphabet, the software in the text.lisp file will 'write' on the screen selecting squares and using this string again to parse a string variable into coordinate in the texture") (defparameter *alphabet* "abcdefghijklmnopqrstuvwxyz-" "this is used to generate the grid, when the coordinates run out of letters they restart from the beginning") (defparameter *tr-texture* nil "this contains the texture of the characters from *tr-string*. This will be used to create text on screen by applying the single letters with render-copy") (defconstant +mouse-button-left+ 1 "this binds the left button") (defconstant +mouse-button-right+ 3 "this binds the right button") (defconstant +mouse-button-middle+ 2 "this binds the scroll button") ;; FIXME: replace with apply system and fixed arguments *mouse-position*, *mouse-previous-position* *viewpoint-offset* (defparameter *mouse-keybinds* (list '(+mouse-button-left+ nil (select-pointer *mouse-position* *entities-list*)) '(+mouse-button-middle+ (panning *viewpoint-offset* (velocity *mouse-position* *mouse-previous-position*)) nil) '(+mouse-button-right+ nil (move-entity *mouse-position*)) ;; '(+mouse-button-right+ nil (push (summon-entry *mouse-position* '(1)) *active-entries*)) ) "This is the mouse-keybinds association list. The first value is the button, the second is the action executed on hold and the third is the action executed on release (if any)") (defparameter *is-grid* t "Parameter for displaying the grid, when nil it does not display a grid, when t it display a grid as defined by the *plane-grid*") (defparameter *is-indexes* t "Parameter for displaying the indexes, when nil it does not display them, when t it uses the grid to create a chessboard like indexes") (defparameter *window-width* 1001) (defparameter *window-height* 750) ;; NOTE: probably they need to be moved below in layers, for now they can stay here (defparameter *map-info* nil "when the json informations are read, the content is dumped into this parameter and then used on uninitialized data to bootstrap the data") (defparameter *map-path* nil "this is the path where the json file lived") ;; this defines the parameters and the defchain macro used to create inversion of ;; control. The parameters cannot be defined outside this function because asdf ;; would initialize them after the functions and break the functionality (defun kick-start-chain () (defparameter *execute-before* nil) (defparameter *execute-in-viewpoint* nil) (defparameter *execute-in-window* nil) (defparameter *execute-after* nil) (defmacro defchain (chain-name where &body body) (cond ((eq where :before) (push chain-name *execute-before*)) ((eq where :viewpoint) (push chain-name *execute-in-viewpoint*)) ((eq where :window) (push chain-name *execute-in-window*)) ((eq where :after) (push chain-name *execute-after*)) ) `(defun ,chain-name () ,@body)) ) (kick-start-chain)