How to declare an icon to show in the editor dialog? - macros

At the very first page of the reference manual of GDScript there is a learn GDscript in x minutes with a line of code which seems to be a macro #icon("path/to.png") but that does not work on the latest version of Godot (v 3.3.stable.mono.official):
#icon minimal example
class_name Player
extends KinematicBody2D
#icon("res://icon.png")
func _ready() -> void:
pass
error
Parser Error: Parse error: Unexpected '#'

You are reading documentation for Godot 4.0 (look in the url, you want "stable" not "latest"). See also GDScript progress report: New GDScript is now merged.
In Godot 3.x to specify an script icon you do it in the class_name statement, like this:
class_name Player, "res://icon.png"
See Register scripts as classes.

Related

Why isn't info popping up when the mouse hovers over a function in a package

When the mouse pointer hovers over the name of a function created in my code a box pops up in the editor with information about that function. However, if the function is in a package nothing happens. For example, if the mouse pointer hovers over the word "DataFrame" in the second line of the code below no box with info pops up. This is not specific to package DataFrames.
using DataFrames
DataFrame(:A => [0])
In VSCode Settings the following is set:
Editor > Hover:Delay
200
Editor > Hover:Enabled
Checked
The IDE is Visual Studio Code version 1.71.2 and the OS is Windows 11. The programming language is Julia, version 1.8.1.
It used to work, something changed, I do not know what.
Any hints on why this is happening?
I believe I found the solution. I created a function that adds a package to the environment. It has the package name as its single argument.
function load_package(package_name::String; used = true, report = true)
str_ui = used ? "Using " : "Importing "
report && println(str_ui * "package $package_name")
if used
eval(Meta.parse("using $package_name"))
end
eval(Meta.parse("import $package_name"))
end
It works fine. The package is loaded. For example,
load_package("DataFrames")
does (almost) the same thing as
using DataFrames
The only difference is that Visual Code does not seem to notice that the package was loaded when the package is loaded with the loaded_package function but it does notice it when the package is loaded with the using command.
So to fix the problem I had to load my packages with using and import comands. After doing that the tooltips became visible upon hovering over the function names.
The reason I was using the function load_packages was to load sets of packages whose names were in string vectors.

Microsoft.Maui.IPropertyMapper - The type '' cannot be used as a type parameter... There is no implicit conversion

I'm trying to get maps to work on .net MAUI and found this blog post (linked to from the official MAUI blog). https://www.cayas.de/blog/dotnet-maui-custom-map-handler
I've downloaded the repo linked at the end of the blog but I can't get it to run.
In the blog post the MapHandler code looks like this:
public static IPropertyMapper<IMap, MapHandler> MapMapper = new PropertyMapper<IMap, MapHandler>(ViewMapper)
{ };
But in the repo it looks like this:
public static IPropertyMapper<MapView, MapHandler> MapMapper = new PropertyMapper<MapView, MapHandler>(ViewMapper)
{ };
Neither of which work for me, as I get the error (at runtime) below.
The type 'MapControlDemo.Handlers.MapHandler' cannot be used as type parameter 'TViewHandler' in the generic type or method 'PropertyMapper<TVirtualView, TViewHandler>'. There is no implicit reference conversion from 'MapControlDemo.Handlers.MapHandler' to 'Microsoft.Maui.IElementHandler'
Confusingly there are another couple of errors that shouldn't be errors??
Any ideas? I contacted the author and he suggested it could be my maui version as it works for him, but I'm on the latest.
Perhaps the author was building on a Mac.
I've confirmed that an attempt to build on Windows results in a build error. VS Version 17.3.0 Preview 1.1
The error I got was
Error CS0311 The type 'MapControlDemo.Handlers.MapHandler' cannot be used
as type parameter 'TViewHandler'
in the generic type or method 'IPropertyMapper<TVirtualView, TViewHandler>'.
There is no implicit reference conversion from
'MapControlDemo.Handlers.MapHandler' to
'Microsoft.Maui.IElementHandler'.
MapControlDemo (net6.0-android) C:\...\maui-maps\Handlers\MapHandler.cs 6
HOWEVER, I was able to RUN on Android - by selected an Android emulator as target (so using net6.0-android) and pressing F5 - therefore that error is misleading.
Given that this is only implemented on iOS and Android, I recommend editing .csproj to REMOVE Windows platform. I also removed MacCatalyst (maybe that would work but I was going for simplest test):
Change:
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
To:
<TargetFrameworks>net6.0-android;net6.0-ios</TargetFrameworks>
Then I was able to build.
NOTE: Without adding a Google Maps ID, when ran on Android, the result was an empty map.
tl;dr Easiest way to test is on a Mac, targetting iOS.

Macro runs on one computer and get run time error 5 on anothe

I run a macro on one computer and it is fine
And on another it gives me the run time error 5: invalid procedure call or argument
This is the code he doesn`t like:
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
Range(Cells(1, 1), Cells(R, C)), Version:=xlPivotTableVersion15).CreatePivotTable _
TableDestination:="ProjectsOW!R3C1", TableName:="PivotTable3", DefaultVersion _
:=xlPivotTableVersion15
Please help!
CAUSE
This problem occurs because the destination worksheet and the range for the new PivotTable are specified in the recorded macro. Therefore, the recorded macro is not dynamic. Additionally, the recorded macro cannot be played repeatedly.
RESOLUTION
To resolve this problem, follow these steps:
In the Microsoft Visual Basic Editor (VBE), locate the code for the recorded macro.
Empty the value of the TableDestination variable as in the following example.
TableDestination=""
On the File menu, click Save.
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
For more info

Is there auto-import functionality for typescript in Visual Studio Code?

Is there any shortcut that will allow me to auto generate my typescript imports? Like hitting ctrl+space next to the type name and having the import declaration placed at the top of the file. If not, what about intellisense for filling out the module reference path so that I wont have to do it manually? I would really love to use vscode but having to do manual imports for typescript is killing me.
There are rumors of making it support tsconfig.json (well, better than rumors). This will allow us to be able to use all files for our references.
Your feature would be to create an auto import of all commonly used 3rd party libs into the typings. Perhaps auto scan the files and create a list of ones to go gather. Wouldn't it be fine to just have a quick way to add several of these using tsd directly from Code (interactively)?
I believe the plugin called "TypeScript Importer" does exactly what You mean: https://marketplace.visualstudio.com/items?itemName=pmneo.tsimporter .
Automatically searches for TypeScript definitions in workspace files and provides all known symbols as completion item to allow code completion.
With it You can truly use Ctrl+Space to choose what exactly You would like to be imported.
You can find and install it from Ctrl+Shift+X menu or just by pasting ext install tsimporter in Quick Open menu opened with Ctrl+P.
I know a solution for Visual Studio (not Visual Studio Code, I'm using the 2015 Community edition, which is free), but it needs some setup and coding -- however, I find the results to be adequate.
Basically, in Visual Studio, when using the Web-Essentials extension, .ts files can be dragged into the active document to automatically generate a relative reference path comment:
/// <reference path="lib/foo.ts" />
With which of course we might as well wipe it, because it's an import statement we need, not a reference comment.
For this reason, I recently wrote the following command snippet for Visual Commander, but it should be easily adaptable to other use casese as well. With Visual Commander, your drag the needed imports into the open document, then run the following macro:
using EnvDTE;
using EnvDTE80;
using System.Text.RegularExpressions;
public class C : VisualCommanderExt.ICommand
{
// Called by Visual Commander extension.
public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
TextDocument doc = (TextDocument)(DTE.ActiveDocument.Object("TextDocument"));
var p = doc.StartPoint.CreateEditPoint();
string s = p.GetText(doc.EndPoint);
p.ReplaceText(doc.EndPoint, this.ReplaceReferences(s), (int)vsEPReplaceTextOptions.vsEPReplaceTextKeepMarkers);
}
// Converts "reference" syntax to "ES6 import" syntax.
private string ReplaceReferences(string text)
{
string pattern = "\\/\\/\\/ *<reference *path *= *\"([^\"]*)(?:\\.ts)\" *\\/>";
var regex = new Regex(pattern);
var matches = Regex.Matches(text, pattern);
return Regex.Replace(text, pattern, "import {} from \"./$1\";");
}
}
When running this snippet, all reference comments in the active document will be replaced with import statements. The above example is converted to:
import {} from "./lib/foo";
This has just been released in version 1.18.
From the release notes:
Auto Import for JavaScript and TypeScript
Speed up your coding with auto imports for JavaScript and TypeScript. The suggestion list now includes all exported symbols in the current project. Just start typing:
If you choose one of the suggestion from another file or module, VS Code will automatically add an import for it. In this example, VS Code adds an import for Hercules to the top of the file:
Auto imports requires TypeScript 2.6+. You can disable auto imports by setting "typescript.autoImportSuggestions.enabled": false.
The files attributes in the tsconfig.json file allows you to set your reference imports in your whole project. It is supported with Visual Studio Code, but please note that if you're using a specific build chain (such as tsify/browserify) it might not work when compiling your project.

Getting an error while writing a custom velocity macro

When creating my own macro, and trying to add it so that anyone can use it, I get the following error:
Error number 4001 in 4: Error while parsing velocity page /templates/docdoesnotexist.vm
Wrapped Exception: Cannot start the Velocity engine
I do not change that file, but I do change xwiki/templates/macros.txt and /macros.vm by adding recentChanges=velocity:recentChanges: and #macro(recentChanges) respectively (yes, I do add working content after #macro(recentChanges))
That looks like a syntax error in macros.vm. You should revert to the original macros.vm and first try to write your custom macro in a wiki page. Once it works, you can move it to macros.vm and restart the server.
macros.txt shouldn't be edited, it's a legacy file used by the older WYSIWYG editor.